Skip to content

Commit

Permalink
Merge pull request #5550 from sandushi/alternative-login-improvement
Browse files Browse the repository at this point in the history
Refactor the UI for email attribute option of alternative login identifiers when email username type is enabled
  • Loading branch information
sandushi authored Mar 15, 2024
2 parents 677328f + fc19806 commit cc4618a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/nasty-lobsters-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/console": patch
---

Improve the alternative login identifier UI
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import List from "@oxygen-ui/react/List";
import ListItem from "@oxygen-ui/react/ListItem";
import ListItemText from "@oxygen-ui/react/ListItemText";
import Typography from "@oxygen-ui/react/Typography";
import { IdentityAppsError } from "@wso2is/core/errors";
import {
AlertLevels,
Claim,
Expand All @@ -40,12 +41,8 @@ import {
Message,
PageLayout
} from "@wso2is/react-components";
import {
ServerConfigurationsConstants
} from "../../../../features/server-configurations/constants";
import { AxiosError } from "axios";
import isEmpty from "lodash-es/isEmpty";
import { IdentityAppsError } from "@wso2is/core/errors";
import React, {
FunctionComponent,
ReactElement,
Expand Down Expand Up @@ -74,6 +71,9 @@ import {
getConnectorDetails,
updateGovernanceConnector
} from "../../../../features/server-configurations/api";
import {
ServerConfigurationsConstants
} from "../../../../features/server-configurations/constants";
import {
ConnectorPropertyInterface,
GovernanceConnectorInterface,
Expand Down Expand Up @@ -237,8 +237,8 @@ export const AlternativeLoginIdentifierEditPage: FunctionComponent<AlternativeLo

resolvedInitialValues = {
...resolvedInitialValues,
email: isEnabled && allowedAttributes?.includes(ClaimManagementConstants.EMAIL_CLAIM_URI) &&
isAlphanumericUsername,
email: (isEnabled && allowedAttributes?.includes(ClaimManagementConstants.EMAIL_CLAIM_URI)) ||
!isAlphanumericUsername,
mobile: isEnabled && allowedAttributes?.includes(ClaimManagementConstants.MOBILE_CLAIM_URI)
};

Expand Down Expand Up @@ -432,11 +432,16 @@ export const AlternativeLoginIdentifierEditPage: FunctionComponent<AlternativeLo
const handleSubmit = (values: AlternativeLoginIdentifierFormInterface) => {

const processedFormValues: AlternativeLoginIdentifierFormInterface = { ...values };
const checkedClaims: string[] = availableClaims
let checkedClaims: string[] = availableClaims
.filter((claim: Claim) =>
processedFormValues[claim?.displayName?.toLowerCase()] !== undefined
? processedFormValues[claim?.displayName?.toLowerCase()] : false)
.map((claim: Claim) => claim?.claimURI);

// Remove the email attribute from the allowed attributes list when email username type is enabled
if (!isAlphanumericUsername) {
checkedClaims = checkedClaims.filter((item: string) => item !== ClaimManagementConstants.EMAIL_CLAIM_URI);
}
const updatedConnectorData: any = getUpdatedConfigurations(checkedClaims);

updateConnector(updatedConnectorData, checkedClaims);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2918,7 +2918,7 @@ export const extensions: Extensions = {
" the login flow.",
warning: "Ensure that each user in your organization has a unique value assigned for the selected" +
" login identifiers.",
info: "You have selected email as the username type which makes it the primary login identifier.",
info: "You've chosen email as your username type, and it automatically serves as a login identifier.",
notification: {
error: {
description: "Error updating the alternative login identifier configuration.",
Expand Down

0 comments on commit cc4618a

Please sign in to comment.