Skip to content

Commit

Permalink
Merge pull request #2428 from sumedhe/multi-attribute-placeholder
Browse files Browse the repository at this point in the history
Set placeholder name according to the multi-attribute login config
  • Loading branch information
sumedhe authored Sep 3, 2021
2 parents d2131ef + 6dc16b7 commit 2cbe4af
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ welcome=Welcome
account.linking=Account Linking
username=Username
email.username=Email address
user.identifier=User Identifier
password=Password
confirm.password=Confirm Password
email=Email
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ welcome=Bienvenue
account.linking=Liaison de compte
username=Nom d'utilisateur
email.username=Courriel (Nom d'utilisateur)
user.identifier=Identifiant de l'utilisateur
password=Mot de passe
confirm.password=Confirmer le mot de passe
email=Courriel
Expand Down
40 changes: 22 additions & 18 deletions apps/authentication-portal/src/main/webapp/basicauth.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,36 @@
Boolean isEmailUsernameEnabled = false;
String usernameLabel = "username";
Boolean isSelfSignUpEnabledInTenant;
Boolean isUsernameRecoveryEnabledInTenant;
Boolean isPasswordRecoveryEnabledInTenant;
Boolean isMultiAttributeLoginEnabledInTenant;
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 = "user.identifier";
}
String resendUsername = request.getParameter("resend_username");
Expand Down Expand Up @@ -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;
}
%>

<div class="buttons">
Expand Down
17 changes: 16 additions & 1 deletion apps/authentication-portal/src/main/webapp/identifierauth.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,32 @@

<%
String emailUsernameEnable = application.getInitParameter("EnableEmailUserName");
Boolean isEmailUsernameEnabled = false;
Boolean isEmailUsernameEnabled;
String usernameLabel = "username";
Boolean isMultiAttributeLoginEnabledInTenant;
if (StringUtils.isNotBlank(emailUsernameEnable)) {
isEmailUsernameEnabled = Boolean.valueOf(emailUsernameEnable);
} else {
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 = "user.identifier";
}
%>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Recover.password=Recover Password
email.username=Email address
Enter.detail.to.recover.pwd=Enter below details to recover your password
Username=Username
User.identifier=User Identifier
Recover.with.mail=Recover with Mail
Recover.with.question=Recover with Security Questions
Submit=Submit
Expand Down Expand Up @@ -100,6 +101,7 @@ Need.to.select.all.mandatory.attributes=You need to select all mandatory attribu
Ok=Ok
Start.signing.up=Start Signing Up
Enter.your.username.here=Enter your username here
Enter.your.user.identifier.here=Enter your user identifier here
If.you.specify.tenant.domain.you.registered.under.super.tenant=If you do not specify a tenant domain, you will be registered under super tenant
Proceed.to.self.register=Proceed to Self Register
Confirm.Privacy.Policy=Please confirm that you have read and understood the Privacy Policy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Identity.server=Identity Server
Recover.password=Récupérez son mot de passe
Enter.detail.to.recover.pwd=Entrer les détails ci-dessous pour récupérer votre mot de passe
Username=Nom d'utilisateur
User.identifier=Identifiant de l'utilisateur
Recover.with.mail=récupérer avec l'adresse mail
Recover.with.question=récupérer avec les questions de sécurité
Submit=Soumettre
Expand Down Expand Up @@ -97,6 +98,7 @@ Need.to.select.all.mandatory.attributes=Vous devez sélectionner tous les attrib
Ok=Ok
Start.signing.up=Commencer la connexion
Enter.your.username.here=Entrer votre nom d'utilisateur ici
Enter.your.user.identifier.here=Entrez votre identifiant ici
If.you.specify.tenant.domain.you.registered.under.super.tenant=Si vous ne spécifiez aucun domaine, vous allez être enregistré en tant que hôte
Proceed.to.self.register=Procéder à l'auto-inscription
Confirm.Privacy.Policy=Veuillez confirmer que vous avez lu et compris la politique de confidentialité
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<%@ page import="org.apache.commons.lang.StringUtils" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointConstants" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.IdentityManagementEndpointUtil" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.PreferenceRetrievalClient" %>
<%@ page import="org.wso2.carbon.identity.mgt.endpoint.util.client.PreferenceRetrievalClientException" %>
<%@ page import="org.wso2.carbon.identity.core.util.IdentityTenantUtil" %>

<jsp:directive.include file="includes/localize.jsp"/>
Expand All @@ -35,6 +37,26 @@
if (StringUtils.isBlank(tenantDomain)) {
tenantDomain = IdentityManagementEndpointConstants.SUPER_TENANT;
}
Boolean isMultiAttributeLoginEnabledInTenant;
try {
PreferenceRetrievalClient preferenceRetrievalClient = new PreferenceRetrievalClient();
isMultiAttributeLoginEnabledInTenant = preferenceRetrievalClient.checkMultiAttributeLogin(tenantDomain);
} catch (PreferenceRetrievalClientException e) {
request.setAttribute("error", true);
request.setAttribute("errorMsg", IdentityManagementEndpointUtil
.i18n(recoveryResourceBundle, "something.went.wrong.contact.admin"));
IdentityManagementEndpointUtil.addErrorInformation(request, e);
request.getRequestDispatcher("error.jsp").forward(request, response);
return;
}
String usernameLabel = "Username";
String enterUsernameHereText = "Enter.your.username.here";
if (isMultiAttributeLoginEnabledInTenant) {
usernameLabel = "User.identifier";
enterUsernameHereText = "Enter.your.user.identifier.here";
}
%>

<html>
Expand Down Expand Up @@ -84,11 +106,11 @@
</div>
<% } %>
<p>
<%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, "Enter.your.username.here")%>
<%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, enterUsernameHereText)%>
</p>
<div class="field">
<label>
<%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, "Username")%>
<%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, usernameLabel)%>
</label>
<input id="username" name="username" type="text" tabindex="0" required>
<%
Expand Down
16 changes: 12 additions & 4 deletions apps/recovery-portal/src/main/webapp/password-recovery.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,26 @@
reCaptchaEnabled = true;
}
Boolean isQuestionBasedPasswordRecoveryEnabledByTenant = false;
Boolean isNotificationBasedPasswordRecoveryEnabledByTenant = false;
Boolean isQuestionBasedPasswordRecoveryEnabledByTenant;
Boolean isNotificationBasedPasswordRecoveryEnabledByTenant;
Boolean isMultiAttributeLoginEnabledInTenant;
try {
PreferenceRetrievalClient preferenceRetrievalClient = new PreferenceRetrievalClient();
isQuestionBasedPasswordRecoveryEnabledByTenant = preferenceRetrievalClient.checkQuestionBasedPasswordRecovery(tenantDomain);
isNotificationBasedPasswordRecoveryEnabledByTenant = preferenceRetrievalClient.checkNotificationBasedPasswordRecovery(tenantDomain);
isMultiAttributeLoginEnabledInTenant = preferenceRetrievalClient.checkMultiAttributeLogin(tenantDomain);
} catch (PreferenceRetrievalClientException e) {
request.setAttribute("error", true);
request.setAttribute("errorMsg", IdentityManagementEndpointUtil
.i18n(recoveryResourceBundle, "something.went.wrong.contact.admin"));
IdentityManagementEndpointUtil.addErrorInformation(request, e);
request.getRequestDispatcher("error.jsp").forward(request, response);
return;
}
String enterUsernameHereText = "Enter.your.username.here";
if (isMultiAttributeLoginEnabledInTenant) {
enterUsernameHereText = "Enter.your.user.identifier.here";
}
%>

Expand Down Expand Up @@ -153,7 +161,7 @@
%>
<div class="field">
<label for="username">
<%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, "Enter.your.username.here")%>
<%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, enterUsernameHereText)%>
</label>
<input id="username" name="username" value="<%=username%>" type="text" tabindex="0" required>
<%
Expand All @@ -171,7 +179,7 @@

<div class="field">
<label for="username">
<%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, "Enter.your.username.here")%>
<%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, enterUsernameHereText)%>
</label>
<input id="username" name="username" type="text" tabindex="0" required>
<%
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@
<carbon.extension.identity.authenticator.version>3.0.0</carbon.extension.identity.authenticator.version>
<org.wso2.carbon.identity.association.account>5.1.5</org.wso2.carbon.identity.association.account>
<identity.extension.utils>1.0.8</identity.extension.utils>
<carbon.identity.framework.version>5.20.142</carbon.identity.framework.version>
<carbon.identity.framework.version>5.20.180</carbon.identity.framework.version>
<carbon.identity.framework.imp.pkg.version.range>[5.0.0, 6.0.0)</carbon.identity.framework.imp.pkg.version.range>
<carbon.identity.oauth.version>6.5.3</carbon.identity.oauth.version>
<carbon.identity.oauth.imp.pkg.version.range>[6.1.0, 7.0.0)</carbon.identity.oauth.imp.pkg.version.range>
Expand Down

0 comments on commit 2cbe4af

Please sign in to comment.