From d611373771c89b10e3eff2afdf53c4edbb2d39ed Mon Sep 17 00:00:00 2001 From: Sumedhe Dissanayake Date: Fri, 3 Sep 2021 02:16:08 +0530 Subject: [PATCH] Set placeholder name according to the multi-attribute login config --- .../endpoint/i18n/Resources.properties | 1 + .../endpoint/i18n/Resources_fr_FR.properties | 1 + .../src/main/webapp/basicauth.jsp | 40 ++++++++++--------- .../src/main/webapp/identifierauth.jsp | 15 +++++++ pom.xml | 1 + 5 files changed, 40 insertions(+), 18 deletions(-) diff --git a/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources.properties b/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources.properties index d0da0044df8..2fd43b1272f 100644 --- a/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources.properties +++ b/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources.properties @@ -21,6 +21,7 @@ welcome=Welcome account.linking=Account Linking username=Username email.username=Email address +identifier.username=Identifier password=Password confirm.password=Confirm Password email=Email diff --git a/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_fr_FR.properties b/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_fr_FR.properties index 57ec0cda8ea..f0a78b3ee7d 100644 --- a/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_fr_FR.properties +++ b/apps/authentication-portal/src/main/resources/org/wso2/carbon/identity/application/authentication/endpoint/i18n/Resources_fr_FR.properties @@ -21,6 +21,7 @@ welcome=Bienvenue account.linking=Liaison de compte username=Nom d'utilisateur email.username=Courriel (Nom d'utilisateur) +identifier.username=Identifiant password=Mot de passe confirm.password=Confirmer le mot de passe email=Courriel diff --git a/apps/authentication-portal/src/main/webapp/basicauth.jsp b/apps/authentication-portal/src/main/webapp/basicauth.jsp index 290c2c78b63..2a7fa32569f 100644 --- a/apps/authentication-portal/src/main/webapp/basicauth.jsp +++ b/apps/authentication-portal/src/main/webapp/basicauth.jsp @@ -118,14 +118,36 @@ Boolean isEmailUsernameEnabled = false; String usernameLabel = "username"; + Boolean isSelfSignUpEnabledInTenant = false; + Boolean isUsernameRecoveryEnabledInTenant = false; + Boolean isPasswordRecoveryEnabledInTenant = false; + Boolean isMultiAttributeLoginEnabledInTenant = false; + if (StringUtils.isNotBlank(emailUsernameEnable)) { isEmailUsernameEnabled = Boolean.valueOf(emailUsernameEnable); } else { isEmailUsernameEnabled = isEmailUsernameEnabled(); } + try { + PreferenceRetrievalClient preferenceRetrievalClient = new PreferenceRetrievalClient(); + isSelfSignUpEnabledInTenant = preferenceRetrievalClient.checkSelfRegistration(tenantDomain); + isUsernameRecoveryEnabledInTenant = preferenceRetrievalClient.checkUsernameRecovery(tenantDomain); + isPasswordRecoveryEnabledInTenant = preferenceRetrievalClient.checkPasswordRecovery(tenantDomain); + isMultiAttributeLoginEnabledInTenant = preferenceRetrievalClient.checkMultiAttributeLogin(tenantDomain); + } catch (PreferenceRetrievalClientException e) { + request.setAttribute("error", true); + request.setAttribute("errorMsg", AuthenticationEndpointUtil + .i18n(resourceBundle, "something.went.wrong.contact.admin")); + IdentityManagementEndpointUtil.addErrorInformation(request, e); + request.getRequestDispatcher("error.jsp").forward(request, response); + return; + } + if (isEmailUsernameEnabled == true) { usernameLabel = "email.username"; + } else if (isMultiAttributeLoginEnabledInTenant) { + usernameLabel = "identifier.username"; } String resendUsername = request.getParameter("resend_username"); @@ -359,24 +381,6 @@ accountRegistrationEndpointURL = identityMgtEndpointContext + ACCOUNT_RECOVERY_ENDPOINT_REGISTER; } } - - Boolean isSelfSignUpEnabledInTenant = false; - Boolean isUsernameRecoveryEnabledInTenant = false; - Boolean isPasswordRecoveryEnabledInTenant = false; - - try { - PreferenceRetrievalClient preferenceRetrievalClient = new PreferenceRetrievalClient(); - isSelfSignUpEnabledInTenant = preferenceRetrievalClient.checkSelfRegistration(tenantDomain); - isUsernameRecoveryEnabledInTenant = preferenceRetrievalClient.checkUsernameRecovery(tenantDomain); - isPasswordRecoveryEnabledInTenant = preferenceRetrievalClient.checkPasswordRecovery(tenantDomain); - } catch (PreferenceRetrievalClientException e) { - request.setAttribute("error", true); - request.setAttribute("errorMsg", AuthenticationEndpointUtil - .i18n(resourceBundle, "something.went.wrong.contact.admin")); - IdentityManagementEndpointUtil.addErrorInformation(request, e); - request.getRequestDispatcher("error.jsp").forward(request, response); - return; - } %>
diff --git a/apps/authentication-portal/src/main/webapp/identifierauth.jsp b/apps/authentication-portal/src/main/webapp/identifierauth.jsp index 0574f0601ec..49b5a7e273e 100644 --- a/apps/authentication-portal/src/main/webapp/identifierauth.jsp +++ b/apps/authentication-portal/src/main/webapp/identifierauth.jsp @@ -39,6 +39,7 @@ String emailUsernameEnable = application.getInitParameter("EnableEmailUserName"); Boolean isEmailUsernameEnabled = false; String usernameLabel = "username"; + Boolean isMultiAttributeLoginEnabledInTenant = false; if (StringUtils.isNotBlank(emailUsernameEnable)) { isEmailUsernameEnabled = Boolean.valueOf(emailUsernameEnable); @@ -46,8 +47,22 @@ isEmailUsernameEnabled = isEmailUsernameEnabled(); } + try { + PreferenceRetrievalClient preferenceRetrievalClient = new PreferenceRetrievalClient(); + isMultiAttributeLoginEnabledInTenant = preferenceRetrievalClient.checkMultiAttributeLogin(tenantDomain); + } catch (PreferenceRetrievalClientException e) { + request.setAttribute("error", true); + request.setAttribute("errorMsg", AuthenticationEndpointUtil + .i18n(resourceBundle, "something.went.wrong.contact.admin")); + IdentityManagementEndpointUtil.addErrorInformation(request, e); + request.getRequestDispatcher("error.jsp").forward(request, response); + return; + } + if (isEmailUsernameEnabled == true) { usernameLabel = "email.username"; + } else if (isMultiAttributeLoginEnabledInTenant) { + usernameLabel = "identifier.username"; } %> diff --git a/pom.xml b/pom.xml index ab77961f801..077ef9711b1 100644 --- a/pom.xml +++ b/pom.xml @@ -657,6 +657,7 @@ 3.0.0 5.1.5 1.0.8 + 5.20.142 [5.0.0, 6.0.0) 6.5.3