Skip to content
Snippets Groups Projects
Commit 07905af1 authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Stop calling SimpleSAML_Session::getAttributes() in SimpleSAML_Error_Error...

Stop calling SimpleSAML_Session::getAttributes() in SimpleSAML_Error_Error class. Use an alternate way to try to fetch user's mail.
parent 44b53ca9
No related branches found
No related tags found
No related merge requests found
......@@ -269,12 +269,15 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception {
$data['errorReportAddress'] = $baseurl . 'errorreport.php';
}
$data['email'] = '';
$session = SimpleSAML_Session::getSessionFromRequest();
$attributes = $session->getAttributes();
if (is_array($attributes) && array_key_exists('mail', $attributes) && count($attributes['mail']) > 0) {
$data['email'] = $attributes['mail'][0];
} else {
$data['email'] = '';
$authorities = $session->getAuthorities();
foreach ($authorities as $authority) {
$attributes = $session->getAuthData($authority, 'Attributes');
if ($attributes !== NULL && array_key_exists('mail', $attributes) && count($attributes['mail']) > 0) {
$data['email'] = $attributes['mail'][0];
break; // enough, don't need to get all available mails, if more than one
}
}
$show_function = $config->getArray('errors.show_function', NULL);
......
......@@ -901,4 +901,21 @@ class SimpleSAML_Session {
return $this->authData[$authority][$name];
}
/**
* Retrieve a list of authorities (authentication sources) that are currently valid within
* this session.
*
* @return mixed An array containing every authority currently valid. Empty if none available.
*/
public function getAuthorities()
{
$authorities = array();
foreach (array_keys($this->authData) as $authority) {
if ($this->isValid($authority)) {
$authorities[] = $authority;
}
}
return $authorities;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment