Ejemplo n.º 1
0
 /** @inheritdoc */
 public function rules()
 {
     return [['email', 'filter', 'filter' => 'trim'], ['email', 'required'], ['email', 'email'], ['email', 'exist', 'targetClass' => $this->module->modelMap['User'], 'message' => \Yii::t('users', 'There is no user with such email.')], ['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('users', 'You need to confirm your email address'));
         }
     }], ['password', 'required'], ['password', 'string', 'min' => 6]];
 }
Ejemplo n.º 2
0
 /** @inheritdoc */
 public function rules()
 {
     return [[['login', 'password'], 'required'], ['login', 'trim'], ['password', function ($attribute) {
         if ($this->user === null || !Password::validate($this->password, $this->user->password_hash)) {
             $this->addError($attribute, \Yii::t('users', 'Invalid login or password'));
         }
     }], ['login', function ($attribute) {
         if ($this->user !== null) {
             $confirmationRequired = $this->module->enableConfirmation && !$this->module->enableUnconfirmedLogin;
             if ($confirmationRequired && !$this->user->getIsConfirmed()) {
                 $this->addError($attribute, \Yii::t('users', 'You need to confirm your email address'));
             }
             if ($this->user->getIsBlocked()) {
                 $this->addError($attribute, \Yii::t('users', 'Your account has been blocked'));
             }
         }
     }], ['rememberMe', 'boolean']];
 }