Beispiel #1
0
 /**
  * Authenticates against the supplied adapter
  *
  * @param  string $username
  * @param  string $password
  * @return Zend_Auth_Result
  */
 public function authenticate($username, $password)
 {
     // Get a reference to the singleton instance of Zend_Auth
     $this->_auth = Zend_Auth::getInstance();
     // Set the storage interface
     $this->_auth->setStorage(new Glo_Auth_Storage_Session('Glo_Auth'));
     // Set the identity on the adapter
     $this->_adapter->setIdentity($username);
     // Set the credential on the adapter
     $this->_adapter->setCredential($password);
     // Attempt authentication, saving the result
     $result = $this->_auth->authenticate($this->_adapter);
     if (!$result->isValid()) {
         // Authentication failed
         throw new Glo_Auth_Exception_Failed(array_shift($result->getMessages()));
     } else {
         $data = $this->_adapter->getResultRowObject(array('user_uuid'));
         $storage = $this->_auth->getStorage();
         $storage->write($data);
     }
     return $result;
 }