diff --git a/lib/SimpleSAML/Error/Error.php b/lib/SimpleSAML/Error/Error.php index bc10ff187f3a9c5f7238c2deb48771e623760262..a08ffddcdcf810cb7ab9391bc782589e9e573575 100644 --- a/lib/SimpleSAML/Error/Error.php +++ b/lib/SimpleSAML/Error/Error.php @@ -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); diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php index fae1e02065b0e67e86ff0b02c3f7ebb45118a84d..369659520e505189e9f04c8ca3f62ac3e4ab6458 100644 --- a/lib/SimpleSAML/Session.php +++ b/lib/SimpleSAML/Session.php @@ -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; + } }