Yii::t('frontend', 'Имя пользователя'), 'password' => Yii::t('frontend', 'Пароль'), 'rememberMe' => Yii::t('frontend', 'Запомнить меня'), ]; } public function validatePassword() { $user = $this->getUser(); if (!$user || !$user->validatePassword($this->password)) { $this->addError('password', Yii::t('frontend', 'Неправильный логин или пароль.')); } } public function login() { if ($this->validate()) { $user = $this->getUser(); $status = $user->testConnection(); if ($status && Yii::$app->user->login($this->getUser(), $this->rememberMe ? Time::SECONDS_IN_A_MONTH : 0)) { return true; } } return false; } public function getUser() { if ($this->user === false) { $this->user = User::findActive()->andWhere(['or', ['username' => $this->identity], ['email' => $this->identity]])->one(); } return $this->user; } }