Exemplo n.º 1
0
 /**
  * Authentificate user by username/password pair
  *
  * @param string $username
  * @param string $password
  * @param boolean $remember
  * @return \Zend\Authentication\Result
  * @throws \Exception
  */
 public function authentificate($username, $password, $remember = false)
 {
     $adapter = $this->authService->getAdapter();
     if (!$adapter instanceof \Zend\Authentication\Adapter\DbTable) {
         throw new \Exception('invalid auth adapter type');
     }
     $adapter->setIdentity($username)->setCredential($password);
     $result = $this->authService->authenticate();
     if ($result->getCode() == \Zend\Authentication\Result::SUCCESS) {
         if ($remember) {
             $this->sessionContainer->getManager()->rememberMe();
         }
         $this->sessionContainer->userEntity = (array) $adapter->getResultRowObject();
     } else {
         $this->sessionContainer->userEntity = null;
     }
     return $result;
 }