mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Мигрирована логика блокировки аккаунтов
This commit is contained in:
@@ -17,13 +17,10 @@ class ActiveUserRule extends AccessRule {
|
||||
protected function matchCustom($action) {
|
||||
$account = $this->getIdentity();
|
||||
|
||||
return $account->status > Account::STATUS_REGISTERED
|
||||
return $account->status === Account::STATUS_ACTIVE
|
||||
&& $account->isAgreedWithActualRules();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \api\models\AccountIdentity|null
|
||||
*/
|
||||
protected function getIdentity() {
|
||||
return Yii::$app->getUser()->getIdentity();
|
||||
}
|
||||
|
@@ -55,7 +55,11 @@ class LoginForm extends ApiForm {
|
||||
// TODO: проверить, не заблокирован ли аккаунт
|
||||
if (!$this->hasErrors()) {
|
||||
$account = $this->getAccount();
|
||||
if ($account->status !== Account::STATUS_ACTIVE) {
|
||||
if ($account->status === Account::STATUS_BANNED) {
|
||||
$this->addError($attribute, E::ACCOUNT_BANNED);
|
||||
}
|
||||
|
||||
if ($account->status === Account::STATUS_REGISTERED) {
|
||||
$this->addError($attribute, E::ACCOUNT_NOT_ACTIVATED);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user