mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Добавлено право на избегание удостоверения личности для внутренних приложений
This commit is contained in:
@@ -3,8 +3,11 @@ namespace api\validators;
|
||||
|
||||
use common\helpers\Error as E;
|
||||
use common\models\Account;
|
||||
use common\rbac\Permissions as P;
|
||||
use yii\base\InvalidConfigException;
|
||||
use yii\di\Instance;
|
||||
use yii\validators\Validator;
|
||||
use yii\web\User;
|
||||
|
||||
class PasswordRequiredValidator extends Validator {
|
||||
|
||||
@@ -18,14 +21,25 @@ class PasswordRequiredValidator extends Validator {
|
||||
*/
|
||||
public $skipOnEmpty = false;
|
||||
|
||||
/**
|
||||
* @var User|string
|
||||
*/
|
||||
public $user = 'user';
|
||||
|
||||
public function init() {
|
||||
parent::init();
|
||||
if (!$this->account instanceof Account) {
|
||||
throw new InvalidConfigException('account should be instance of ' . Account::class);
|
||||
}
|
||||
|
||||
$this->user = Instance::ensure($this->user, User::class);
|
||||
}
|
||||
|
||||
protected function validateValue($value) {
|
||||
if ($this->user->can(P::ESCAPE_IDENTITY_VERIFICATION)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (empty($value)) {
|
||||
return [E::PASSWORD_REQUIRED, []];
|
||||
}
|
||||
|
Reference in New Issue
Block a user