Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Authenticator extends Object implements IAuthenticator
- {
- public function authenticate(array $logindata)
- {
- $username = $logindata[self::USERNAME];
- $password = Utils::encodePass($logindata[self::PASSWORD]);
- $result = dibi::query("select * from [is_users] where username=%s", $username)->fetch();
- if (!$result) // nebyl nalezen zaznam v DB, uzivatel neexistuje
- {
- throw new AuthenticationException("Zadaný uživatel '$username' neexistuje!", self::IDENTITY_NOT_FOUND);
- }
- if ($result->password !== $password)
- {
- throw new AuthenticationException("Zadali jste nesprávné heslo!", self::INVALID_CREDENTIAL);
- }
- if ($result->blocked === 'yes')
- {
- throw new AuthenticationException("Blokovany uzivatel!", self::INVALID_CREDENTIAL);
- }
- $identita = new Identity($username, $result->role);
- $identita->realname = $result->jmeno." ".$result->prijmeni;
- $identita->id = $result->id;
- return $identita;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement