/** @inheritdoc */ public function rules() { return ['emailTrim' => ['email', 'filter', 'filter' => 'trim'], 'emailRequired' => ['email', 'required'], 'emailPattern' => ['email', 'email'], 'emailExist' => ['email', 'exist', 'targetClass' => $this->module->modelMap['User'], 'message' => Yii::t('user', 'There is no user with this email address')], 'emailUnconfirmed' => ['email', function ($attribute) { $this->user = $this->finder->findUserByEmail($this->email); if ($this->user !== null && $this->module->enableConfirmation && !$this->user->getIsConfirmed()) { $this->addError($attribute, Yii::t('user', 'You need to confirm your email address')); } }], 'passwordRequired' => ['password', 'required'], 'passwordLength' => ['password', 'string', 'min' => 6]]; }
/** @inheritdoc */ public function rules() { return ['requiredFields' => [['login', 'password'], 'required'], 'loginTrim' => ['login', 'trim'], 'passwordValidate' => ['password', function ($attribute) { if ($this->user === null || !Password::validate($this->password, $this->user->password_hash)) { $this->addError($attribute, Yii::t('user', 'Invalid login or password')); } }], 'confirmationValidate' => ['login', function ($attribute) { if ($this->user !== null) { $confirmationRequired = $this->module->enableConfirmation && !$this->module->enableUnconfirmedLogin; if ($confirmationRequired && !$this->user->getIsConfirmed()) { $this->addError($attribute, Yii::t('user', 'You need to confirm your email address')); } if ($this->user->getIsBlocked()) { $this->addError($attribute, Yii::t('user', 'Your account has been blocked')); } } }], 'rememberMe' => ['rememberMe', 'boolean']]; }