Пример #1
0
 public function authenticate(array $credentials)
 {
     list($username, $password) = $credentials;
     $loginData = $this->localLoginModel->getBy(array("user.email" => $username));
     if (!$loginData) {
         throw new \Nette\Security\AuthenticationException('Neznámé jméno uživatele.', self::IDENTITY_NOT_FOUND);
     } elseif (!Passwords::verify($password, $loginData["password"])) {
         throw new \Nette\Security\AuthenticationException('Nesprávné heslo.', self::INVALID_CREDENTIAL);
     } elseif (Passwords::needsRehash($loginData["password"])) {
         $this->localLoginModel->update($loginData->user_id, array("password" => Passwords::hash($password)));
     }
     $identity = $this->buildIdentity($loginData->user_id);
     $enabled = $identity->getData()["enabled"];
     if (!$enabled) {
         throw new \Nette\Security\AuthenticationException('Tento účet je zablokovaný.', self::INACTIVE);
     }
     $this->user->login($identity);
 }
Пример #2
0
 public function authenticate(array $credentials)
 {
     list($username, $password) = $credentials;
     $loginData = $this->imapLoginModel->getBy(array("username" => $username));
     $mbox = imap_open("{localhost:993/ssl/novalidate-cert}INBOX", $username, $password, OP_HALFOPEN | OP_SILENT);
     imap_alerts();
     imap_errors();
     if (!$loginData) {
         throw new \Nette\Security\AuthenticationException('Neznámé jméno uživatele.', self::IDENTITY_NOT_FOUND);
     } elseif (!$mbox) {
         throw new \Nette\Security\AuthenticationException('Nesprávné heslo.', self::INVALID_CREDENTIAL);
     }
     $identity = $this->buildIdentity($loginData->user_id);
     $enabled = $identity->getData()["enabled"];
     if (!$enabled) {
         throw new \Nette\Security\AuthenticationException('Tento účet je zablokovaný.', self::INACTIVE);
     }
     $this->user->login($identity);
 }