Мигрирована логика блокировки аккаунтов

This commit is contained in:
ErickSkrauch
2016-08-22 00:09:14 +03:00
parent b57b015f66
commit 72a7f743be
5 changed files with 22 additions and 7 deletions

View File

@@ -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();
}

View File

@@ -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);
}
}