Commit a7b09164 authored by Robert Lyon's avatar Robert Lyon

Bug 1859115: Add SAML specific error message when user not found

To be able to extend the UserNotFound error message with SAML specific
information

behatnotneeded

Change-Id: Ic1407cbb6d62909ddb727e838c5a1795da4ed017
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 0cf441f3
......@@ -159,7 +159,7 @@ $instance = auth_saml_find_authinstance($saml_attributes);
// if we don't have an auth instance then this is a serious failure
if (!$instance) {
throw new UserNotFoundException(get_string('errorbadinstitution', 'auth.saml'));
throw new SamlUserNotFoundException(get_string('errorbadinstitution', 'auth.saml'));
}
if ($SESSION->get('migratecheck')) {
......@@ -182,7 +182,7 @@ try {
$can_login = $auth->request_user_authorise($saml_attributes);
}
catch (AccessDeniedException $e) {
throw new UserNotFoundException(get_string('errnosamluser', 'auth.saml'));
throw new SamlUserNotFoundException(get_string('errnosamluser', 'auth.saml'));
}
catch (XmlrpcClientException $e) {
throw new AccessDeniedException($e->getMessage());
......@@ -217,7 +217,7 @@ if ($can_login) {
// are we configured to allow testing of local login and linking?
$loginlink = get_field('auth_instance_config', 'value', 'field', 'loginlink', 'instance', $instance->id);
if (empty($loginlink)) {
throw new UserNotFoundException(get_string('errnosamluser', 'auth.saml'));
throw new SamlUserNotFoundException(get_string('errnosamluser', 'auth.saml'));
}
// used in the submit callback for auth_saml_loginlink_screen()
......
......@@ -83,3 +83,4 @@ $string['warninstitutionregistrationinstitutions'] = array(
);
$string['warnmultiinstitutionsoff'] = '$cfg->usersuniquebyusername is turned on but the site option \'Users allowed multiple institutions\' is off. This makes no sense, as users will then change institution every time they log in from somewhere else. Please turn this setting on in Administration -> Configure site -> Institution settings.';
$string['alternativelogins'] = 'Administration login';
$string['unabletosigninviasso'] = 'Unable to sign in via external authentication (SSO)';
......@@ -968,6 +968,17 @@ class ViewLimitExceededException extends UserException {}
*/
class UserNotFoundException extends NotFoundException {}
/**
* Exception - user not found while doing SAML authentication
*/
class SamlUserNotFoundException extends UserNotFoundException {
public function strings() {
return array_merge(parent::strings(),
array('message' => get_string('invaliduser', 'error')),
array('title' => get_string('unabletosigninviasso', 'auth')));
}
}
/**
* Exception - user not found while doing XMLRPC authentication
*/
......
Markdown is supported
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