/** * Generate a full password reset request for an account * * @param Account $account * @return PasswordResetRequest */ public static function generate(Account $account, $nonce = null) { $nonce = $nonce !== null ? $nonce : Crypto::nonce(); return self::create(['_account_id' => $account->id(), 'nonce' => $nonce]); }
/** * Actual login! Performs the login of a user using pre-vetted info! * * Creates the cookie and session stuff for the login process. * * @param Account $account * @param Player $player * @return void */ private function createGameSession(Account $account, Player $player) { $_COOKIE['username'] = $player->name(); $session = SessionFactory::getSession(); $session->set('username', $player->name()); $session->set('player_id', $player->id()); $session->set('account_id', $account->id()); $session->set('authenticated', true); $request = RequestWrapper::$request; $user_ip = $request->getClientIp(); query('UPDATE players SET active = 1, days = 0 WHERE player_id = :player', [':player' => [$player->id(), PDO::PARAM_INT]]); query('UPDATE accounts SET last_ip = :ip, last_login = now() WHERE account_id = :account', [':ip' => $user_ip, ':account' => [$account->id(), PDO::PARAM_INT]]); }
/** * Generate a full password reset request for an account * * @param Account $account * @return PasswordResetRequest */ public static function generate(Account $account, $nonce = null) { $nonce = $nonce !== null ? $nonce : nonce(); return PasswordResetRequest::create(['_account_id' => $account->id(), 'nonce' => $nonce]); }
/** * Update the time of last failed login. */ public static function updateLastLoginFailure(Account $account) { $update = "UPDATE accounts SET last_login_failure = now() WHERE account_id = :account_id"; return query($update, [':account_id' => [$account->id(), PDO::PARAM_INT]]); }