Beispiel #1
0
 /**
  * @param array $credentials
  * @return Identity|\Nette\Security\IIdentity
  * @throws \Nette\Security\AuthenticationException
  */
 public function authenticate(array $credentials)
 {
     if ($this->checkConnection->invoke()) {
         try {
             /** @var $user \CmsModule\Pages\Users\UserEntity */
             $user = $this->userRepository->createQueryBuilder('a')->join('a.loginProviders', 's')->where('s.type = :type AND s.uid = :uid')->setParameter('type', static::getType())->setParameter('uid', $this->getLoginProviderEntity()->getUid())->getQuery()->getSingleResult();
         } catch (\Doctrine\ORM\NoResultException $e) {
         }
         if (!isset($user) || !$user) {
             throw new AuthenticationException('User does not exist.', self::INVALID_CREDENTIAL);
         }
         return new Identity($user->getId(), $user->getRoles());
     }
 }