/** * Attempts a login * * @param $username * * @param $password * * @return bool */ public function Attempt($username, $password) { /** * Lets get our userid */ $user_id = $this->user->ToUserID($username); /** * Is our userID null? */ if ($user_id == null) { $this->AddError('The information you have entered is invalid.'); return false; } /** * If not, lets create a new class */ $user = $this->user->ToClass($user_id); /** * Is this user allowed to attempt to login to this user_id? */ if ($this->securelogin->AllowAttempt($user_id, $this->GetAddress()) == false) { $this->AddError('You have been banned from attempting a login for 15 minutes.'); return false; } /** * Lets now match all of our data */ if ($user != null) { /** * Lets go ahead and hash our password */ $hashed_password = $this->HashPassword($password, $user->GetSalt()); /** * Check */ if ($hashed_password == $user->GetPassword()) { /** * Create a new session. */ $this->session->Create($user_id); /** * Return true */ return true; } /** * Else wrong password */ $this->AddError('The information you have entered is invalid.'); /** * Add an attempt */ $this->securelogin->AddAttempt($user_id, $this->GetAddress()); /** * Return false. */ return false; } /** * Information invalid */ $this->AddError('The information you have entered is invalid.'); return false; }