Advertisement
fabi0

Untitled

May 26th, 2014
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. public function login($user_name, $user_password) {
  2.         $sql = "
  3.            SELECT *
  4.            FROM users
  5.            LEFT JOIN `privileges`
  6.            ON `privileges`.privileges_id = users.user_privileges
  7.            WHERE user_name = :user AND user_ban = 0";
  8.  
  9.         $params = array(
  10.             ':user' => array(
  11.                 'param' => (string) $user_name,
  12.                 'type' => 2
  13.             )
  14.         );
  15.  
  16.         $this->_databaseInstance->query($sql, $params, 2);
  17.  
  18.         if (empty($this->_databaseInstance->getCount())) {
  19.             // 201 Несъществуващо име.
  20.             $this->_errors[201] = 1;
  21.             return FALSE;
  22.         }
  23.  
  24.         $user_credentials = $this->_databaseInstance->getResult()[0];
  25.  
  26.         if (!password_verify($user_password, $user_credentials['user_password'])) {
  27.             // 202 Грешна парола.
  28.             $this->_errors[201] = 1;
  29.             return FALSE;
  30.         }
  31.         unset($user_credentials['user_password']);
  32.  
  33.         return $user_credentials;
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement