/** * Tries to login with username and password * * @access protected * @param string $sUsername The username * @param mixed $sPassword The Password * @return bool */ protected function _doLogin($sUsername, $sPassword) { if (Failed_login_attempts::model()->isLockedOut()) { return false; } $identity = new UserIdentity(sanitize_user($sUsername), $sPassword); if (!$identity->authenticate()) { Failed_login_attempts::model()->addAttempt(); return false; } else { return true; } }
/** * Get the authentication failed error messages * @return array Data */ private function _getAuthenticationFailedErrorMessage() { $clang = $this->getController()->lang; $aData = array(); $userHostAddress = Yii::app()->request->getUserHostAddress(); $bUserNotFound = Failed_login_attempts::model()->addAttempt($userHostAddress); if ($bUserNotFound) { $aData['errormsg'] = $clang->gT('Incorrect username and/or password!'); $aData['maxattempts'] = ''; } $bLockedOut = Failed_login_attempts::model()->isLockedOut($userHostAddress); if ($bLockedOut) { $aData['maxattempts'] = sprintf($clang->gT('You have exceeded the number of maximum login attempts. Please wait %d minutes before trying again.'), Yii::app()->getConfig('timeOutTime') / 60); } return $aData; }