Commit 5568859b authored by Tim Steiner's avatar Tim Steiner
Browse files

Added a method to Unl_Auth_Cas_Adapter to determin if it was used to authenticate the current user.

parent 0aa8124e
......@@ -45,8 +45,11 @@ class Unl_Auth_Adapter_Cas implements Zend_Auth_Adapter_Interface
*/
public function authenticate()
{
$session = new Zend_Session_Namespace(__CLASS__);
unset($session->currentUser);
if ($this->_adapter->getTicket()) {
if ($this->_adapter->validateTicket()) {
$session->currentUser = $this->_adapter->getUsername();
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $this->_adapter->getUsername(), array('Authentication successful.'));
} else {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE, NULL, array('Invalid or expired CAS ticket.'));
......@@ -56,4 +59,20 @@ class Unl_Auth_Adapter_Cas implements Zend_Auth_Adapter_Interface
}
}
/**
* Returns TRUE if the currently logged in user (if any) was authenticated by this adapter.
* @return bool
*/
public static function isCasSession()
{
$session = new Zend_Session_Namespace(__CLASS__);
if (isset($session->currentUser) &&
Zend_Auth::getInstance()->hasIdentity() &&
Zend_Auth::getInstance()->getIdentity() == $session->currentUser) {
return TRUE;
}
return FALSE;
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment