Skip to content

Commit

Permalink
Merge pull request #7098 from DilshanSenarath/jit-issues
Browse files Browse the repository at this point in the history
Fix the issue in the self-registration flow when the email address is configured as a unique value
  • Loading branch information
DilshanSenarath authored Nov 13, 2024
2 parents 0cd0f25 + 807b6cb commit c32a62b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .changeset/swift-humans-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/identity-apps-core": patch
---

Fix the issue in the self-registration flow when the email address is configured as a unique value
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
JSONObject usernameValidityResponse;
String username = request.getParameter("username");
String password = request.getParameter("password");
String emailValue = request.getParameter("username");
String consentPurposeGroupName = "SELF-SIGNUP";
String consentPurposeGroupType = "SYSTEM";
String[] missingClaimList = new String[0];
Expand Down Expand Up @@ -147,10 +146,17 @@
// Get validation configuration.
ValidationConfigurationRetrievalClient validationConfigurationRetrievalClient = new ValidationConfigurationRetrievalClient();
JSONObject passwordConfig = null;
JSONObject usernameConfig = null;
try {
passwordConfig = validationConfigurationRetrievalClient.getPasswordConfiguration(tenantDomain);
usernameConfig = validationConfigurationRetrievalClient.getUsernameConfiguration(tenantDomain);
} catch (Exception e) {
passwordConfig = null;
usernameConfig = null;
}
Boolean isAlphanumericUsernameEnabled = false;
if (usernameConfig.has("alphanumericFormatValidator")) {
isAlphanumericUsernameEnabled = (Boolean) usernameConfig.get("alphanumericFormatValidator");
}
try {
Expand Down Expand Up @@ -435,7 +441,7 @@
class="form-control required usrName usrNameLength">
</div>
<div id="passwordField" class="field required">
<label for="passwordUserInput" class="control-label"><%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, "Password")%></label>
<label for="password" class="control-label"><%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, "Password")%></label>
<div class="ui fluid left icon input addon-wrapper">
<input
class="form-control"
Expand Down Expand Up @@ -525,26 +531,39 @@
<% Claim emailNamePII =
uniquePIIs.get(IdentityManagementEndpointConstants.ClaimURIs.EMAIL_CLAIM);
if (emailNamePII != null) {
String emailValue = request.getParameter("username");
if (isAlphanumericUsernameEnabled) {
emailValue = request.getParameter(IdentityManagementEndpointConstants.ClaimURIs.EMAIL_CLAIM);
}
%>
<input type="hidden" name="http://wso2.org/claims/emailaddress" class="form-control"
data-validate="email"
<% if (MultitenantUtils.isEmailUserName()) { %>
value="<%= Encode.forHtmlAttribute(user.getUsername())%>" readonly
<% } %>
<% if (emailNamePII.getValidationRegex() != null) {
String pattern = Encode.forHtmlContent(emailNamePII.getValidationRegex());
String[] patterns = pattern.split("\\\\@");
String regex = StringUtils.join(patterns, "@");
%>
pattern="<%= regex %>"
<% } %>
<% if (emailNamePII.getRequired() || !piisConfigured) {%> required <%}%>
<% if
(skipSignUpEnableCheck && StringUtils.isNotEmpty(emailValue)) {%>
disabled<%}%>
value="<%= Encode.forHtmlAttribute(emailValue)%>"
placeholder="<%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, "Email")%>"
/>
<div class="<% if (emailNamePII.getRequired() || !piisConfigured) {%> required <%}%> field">
<label for="email" class="control-label">
<%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, "Email")%>
</label>
<input
id="email"
type="<% if (isAlphanumericUsernameEnabled) {%>email<%} else {%>hidden<%}%>"
name="http://wso2.org/claims/emailaddress"
class="form-control"
data-validate="email"
<% if (MultitenantUtils.isEmailUserName()) { %>
value="<%= Encode.forHtmlAttribute(user.getUsername())%>" readonly
<% } %>
<% if (emailNamePII.getValidationRegex() != null) {
String pattern = Encode.forHtmlContent(emailNamePII.getValidationRegex());
String[] patterns = pattern.split("\\\\@");
String regex = StringUtils.join(patterns, "@");
%>
pattern="<%= regex %>"
<% } %>
<% if (emailNamePII.getRequired() || !piisConfigured) {%> required <%}%>
<% if
(skipSignUpEnableCheck && StringUtils.isNotEmpty(emailValue)) {%>
disabled<%}%>
value="<% if (StringUtils.isNotEmpty(emailValue)) { %><%=Encode.forHtmlAttribute(emailValue)%><% } %>"
placeholder="<%=IdentityManagementEndpointUtil.i18n(recoveryResourceBundle, "Email")%>"
/>
</div>
<%
}
Expand Down

0 comments on commit c32a62b

Please sign in to comment.