public function testWithUnknownLogin() { try { UsersLogin::login(self::UnknownLogin, self::Password); } catch (\NotFoundException $e) { } $attempt = new LoginAttempt(); $this->AssertTrue($attempt->get(1)); $this->assertEquals($attempt->user_id->getValue(), 0); $this->assertEquals($attempt->status->getValue(), LoginAttempt::FailStatus); }
public static function login($login, $password, $remember = false) { CMSLog::addMessage(self::LogName, sprintf('Login attempt into "%s"', $login)); try { UsersLogin::testLoginAttempts(); } catch (\Extasy\Users\login\LoginAttemptsException $e) { CMSLog::addMessage(__CLASS__, sprintf('Login attempts limit exceeded')); CMSLog::addMessage(__CLASS__, $e); try { $user = UserAccount::getByLogin($login); $e->blockUser($user); throw $e; } catch (\NotFoundException $e) { } return; } try { $user = UserAccount::getByLogin($login); self::isAuthPassed($user, $password); \Extasy\Users\login\LoginAttempt::quickRegister($user, true); } catch (\Exception $e) { \Extasy\Users\login\LoginAttempt::quickRegister(!empty($user) ? $user : null, false); throw $e; } self::testConfirmationCode($user); $user->updateLastActivityDate(); // write to session login self::setupSession($user->getData(), $remember); // self::$currentUser = $user; // CMSLog::addMessage(self::LogName, sprintf('User identified as "%s"', $login)); // Вызываем обработку события, на вход в каждый перехватчик передается текущий объект пользователя EventController::callEvent('users_after_login', $user); }