Example #1
0
 public function Login($handle, $pass)
 {
     try {
         if ($this->is_empty($handle, $pass)) {
             throw new Exception(FORMINCOMPLETE_ERROR_MSG);
         }
         if (!($userData = $this->getUserData($handle))) {
             throw new Exception(USER_ERROR_MSG);
         }
         if (!Bcrypt::Authenticate($pass, $userData['hash'])) {
             throw new Exception(PASSWORD_ERROR_MSG);
         }
         if (!($this->createSession($userData['handle']) && ($this->user = $this->getUserData($handle)))) {
             throw new Exception(SESSION_ERROR_MSG);
         }
         // Clear any password recovery tickets that exist in the database
         $this->clearRecoveryTickets($userData['id']);
         return true;
     } catch (Exception $e) {
         $this->error = $e->getMessage();
     }
     return false;
 }