Esempio n. 1
0
 /**
  * Performs an authentication against e.g. database.
  * and returns IIdentity on success or throws AuthenticationException
  * @return Nette\Security\Identity
  * @throws Nette\Security\AuthenticationException
  */
 function authenticate(array $credentials)
 {
     list($username, $password) = $credentials;
     $result = $this->dataModel->login($username, $password);
     $clientId = (int) $result->ID_KLIENT;
     if (!$clientId) {
         throw new Security\AuthenticationException('Nesprávné přihlašovací údaje.');
     }
     $clientResult = $this->dataModel->getClientData($clientId);
     $data = array('isAdmin' => isset($this->adminList[$clientId]), 'id' => $clientId, 'login_id' => (int) $result->ID_PRIHLASENI, 'name_full' => (string) $clientResult->JMENO . ' ' . (string) $clientResult->PRIJMENI, 'name' => (string) $clientResult->JMENO, 'lastname' => (string) $clientResult->PRIJMENI, 'email' => (string) $clientResult->EMAIL, 'phone' => (string) $clientResult->TEL_MOB, 'credits' => (int) $clientResult->KREDIT, 'info' => (string) $clientResult->POPIS);
     return new Security\Identity($clientId, null, $data);
 }