Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. public function authorize($username, $password, $remember=false)
  2.     {
  3.         $query = "select id, username from users where
  4.            username = :username and password = :password limit 1";
  5.         $sth = $this->db->prepare($query);
  6.         $salt = $this->getSalt($username);
  7.  
  8.         if (!$salt) {
  9.             return false;
  10.         }
  11.  
  12.         $hashes = $this->passwordHash($password, $salt);
  13.         $sth->execute(
  14.             array(
  15.                 ":username" => $username,
  16.                 ":password" => $hashes['hash'],
  17.             )
  18.         );
  19.         $this->user = $sth->fetch();
  20.  
  21.         if (!$this->user) {
  22.             $this->is_authorized = false;
  23.         } else {
  24.             $this->is_authorized = true;
  25.             $this->user_id = $this->user['id'];
  26.             $this->saveSession($remember);
  27.         }
  28.  
  29.         return $this->is_authorized;
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement