Commit 88efddf3 authored by Tim Steiner's avatar Tim Steiner
Browse files

Fix getUsername() and add a method to destroy a session.

parent d6eca3b5
......@@ -160,7 +160,7 @@ class Unl_Cas
*/
public function getUsername()
{
return $this->_username;
return $this->_session->username;
}
/**
......@@ -291,7 +291,6 @@ class Unl_Cas
if ($response->isSuccessful() && $this->_parseResponse($response->getBody())) {
$this->_addValidTicket($ticket);
$this->_session->ticket = $ticket;
$this->_session->username = $this->getUsername();
return true;
}
return false;
......@@ -309,7 +308,7 @@ class Unl_Cas
if ($xml->loadXML($response)) {
if ($success = $xml->getElementsByTagName('authenticationSuccess')) {
if ($success->length > 0 && $uid = $success->item(0)->getElementsByTagName('user')) {
$this->_username = $uid->item(0)->nodeValue;
$this->_session->username = $uid->item(0)->nodeValue;
return true;
}
}
......@@ -324,7 +323,6 @@ class Unl_Cas
private function _removeValidTicket($ticket)
{
echo 'Removing ticket ' . $ticket . PHP_EOL;
$this->_getTicketCache()->remove(hash('sha512', $ticket));
}
......@@ -381,5 +379,12 @@ class Unl_Cas
$this->_removeValidTicket($ticket);
exit;
}
public function destroySession()
{
$this->_removeValidTicket($this->_session->ticket);
$this->_session->ticket = NULL;
$this->_session->username = NULL;
}
}
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