Advertisement
Guest User

Untitled

a guest
May 28th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.46 KB | None | 0 0
  1. <?php
  2.  
  3.         class Authenticator extends Object implements IAuthenticator
  4.         {
  5.                 public function authenticate(array $logindata)
  6.                 {
  7.                         $username = $logindata[self::USERNAME];
  8.                         $password = Utils::encodePass($logindata[self::PASSWORD]);
  9.  
  10.                         $result = dibi::query("select * from [is_users] where username=%s", $username)->fetch();
  11.  
  12.                         if (!$result) // nebyl nalezen zaznam v DB, uzivatel neexistuje
  13.                         {
  14.                                 throw new AuthenticationException("Zadaný uživatel '$username' neexistuje!", self::IDENTITY_NOT_FOUND);
  15.                         }
  16.  
  17.                         if ($result->password !== $password)
  18.                         {
  19.                                 throw new AuthenticationException("Zadali jste nesprávné heslo!", self::INVALID_CREDENTIAL);
  20.                         }
  21.  
  22.                         if ($result->blocked === 'yes')
  23.                         {
  24.                                 throw new AuthenticationException("Blokovany uzivatel!", self::INVALID_CREDENTIAL);
  25.                         }
  26.  
  27.                         $identita = new Identity($username, $result->role);
  28.                         $identita->realname = $result->jmeno." ".$result->prijmeni;
  29.                         $identita->id = $result->id;
  30.  
  31.                         return $identita;
  32.  
  33.                 }
  34.         }
  35.  
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement