From c9d1684fdef77931f5579686f3d59d01a41b9d93 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Thu, 2 Jun 2022 13:18:09 -0500 Subject: [PATCH] Plugin: OAuth2: Improve message when user creation is not enabled - refs BT#19734 --- plugin/oauth2/lang/english.php | 2 +- plugin/oauth2/src/OAuth2.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/plugin/oauth2/lang/english.php b/plugin/oauth2/lang/english.php index 2894d528b3..f9c85b3597 100644 --- a/plugin/oauth2/lang/english.php +++ b/plugin/oauth2/lang/english.php @@ -124,7 +124,7 @@ $strings['FailedUserCreation'] = 'User account creation failed'; $strings['InternalErrorCannotGetUserInfo'] = 'Internal error: could not get user information'; $strings['InvalidJsonReceivedFromProvider'] = 'The OAuth2 provider did not provide a valid JSON document'; $strings['ManagementLogin'] = 'Management Login'; -$strings['NoUserHasThisOauthCode'] = 'No existing user has this OAuth2 code'; +$strings['NoUserAccountAndUserCreationNotAllowed'] = 'This user doesn\'t have an account yet and auto-provisioning is not enabled. Please contact this portal administration team at %s to request access.'; $strings['OAuth2Id'] = 'OAuth2 identifier'; $strings['UserNotAllowedOnThisPortal'] = 'This user account is not enabled on this portal'; $strings['WrongResponseResourceOwnerId'] = 'OAuth2 resource owner identifier value not found at the configured key'; diff --git a/plugin/oauth2/src/OAuth2.php b/plugin/oauth2/src/OAuth2.php index ec66b4bace..9b4df03123 100644 --- a/plugin/oauth2/src/OAuth2.php +++ b/plugin/oauth2/src/OAuth2.php @@ -207,7 +207,14 @@ class OAuth2 extends Plugin if (false === $result) { // authenticated user not found in internal database if ('true' !== $this->get(self::SETTING_CREATE_NEW_USERS)) { - throw new RuntimeException($this->get_lang('NoUserHasThisOauthCode')); + throw new RuntimeException( + sprintf( + $this->get_lang('NoUserAccountAndUserCreationNotAllowed'), + Display::encrypted_mailto_link( + api_get_setting('emailAdministrator') + ) + ) + ); } $firstName = $this->getValueByKey(