/** @inheritdoc */ public function rules() { return [['email', 'filter', 'filter' => 'trim'], ['email', 'required'], ['email', 'email'], ['email', 'exist', 'targetClass' => $this->module->modelMap['User'], 'message' => \Yii::t('user', '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('user', 'You need to confirm your email address')); } }], ['password', 'required'], ['password', 'string', 'min' => 6]]; }
/** * Validates form and logs the user in. * @return boolean whether the user is logged in successfully */ public function login() { if ($this->validate()) { $success = \Yii::$app->getUser()->login($this->user, $this->rememberMe ? $this->module->rememberFor : 0); $this->createHistoryEntry($success); $this->user->updateAttributes(['login_count' => $this->user->login_count + 1]); return $success; } else { return false; } }