Skip to content

Commit

Permalink
Merge pull request wso2#4720 from Achintha444/master
Browse files Browse the repository at this point in the history
(fix) Fix custom attribute not setting/changing properly
  • Loading branch information
Achintha Isuru authored Nov 20, 2023
2 parents 6902def + 641bef5 commit bb713a0
Showing 3 changed files with 53 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/thick-shoes-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/console": patch
---

(fix) Fix custom attribute not setting/changing properly
3 changes: 1 addition & 2 deletions apps/console/src/features/users/components/edit-user.tsx
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ import { FeatureConfigInterface } from "../../core/models";
import { AppState, store } from "../../core/store";
import { useGetCurrentOrganizationType } from "../../organizations/hooks/use-get-organization-type";
import { ConnectorPropertyInterface } from "../../server-configurations/models";
import { AdminAccountTypes, UserManagementConstants } from "../constants";
import { UserManagementConstants } from "../constants";

interface EditUserPropsInterface extends SBACInterface<FeatureConfigInterface> {
/**
@@ -214,7 +214,6 @@ export const EditUser: FunctionComponent<EditUserPropsInterface> = (
connectorProperties={ connectorProperties }
isReadOnlyUserStoresLoading={ isReadOnlyUserStoresLoading }
isUserManagedByParentOrg={ isUserManagedByParentOrg }
adminUserType={ AdminAccountTypes.INTERNAL }
/>
</ResourceTab.Pane>
)
59 changes: 47 additions & 12 deletions apps/console/src/features/users/components/user-profile.tsx
Original file line number Diff line number Diff line change
@@ -315,11 +315,21 @@ export const UserProfile: FunctionComponent<UserProfilePropsInterface> = (
} else {
const schemaName:string = schemaNames[0];

if (schema.extended && userInfo[ProfileConstants.SCIM2_WSO2_USER_SCHEMA]) {
if (schema.extended && userInfo[ProfileConstants.SCIM2_ENT_USER_SCHEMA]
&& userInfo[ProfileConstants.SCIM2_ENT_USER_SCHEMA][schemaNames[0]]) {
tempProfileInfo.set(
schema.name, userInfo[ProfileConstants.SCIM2_WSO2_USER_SCHEMA][schemaName]
schema.name, userInfo[ProfileConstants.SCIM2_ENT_USER_SCHEMA][schemaNames[0]]
);


return;
}

if (schema.extended && userInfo[ProfileConstants.SCIM2_WSO2_USER_SCHEMA]
&& userInfo[ProfileConstants.SCIM2_WSO2_USER_SCHEMA][schemaNames[0]]) {
tempProfileInfo.set(
schema.name, userInfo[ProfileConstants.SCIM2_WSO2_CUSTOM_SCHEMA][schemaNames[0]]
);

return;
}
tempProfileInfo.set(schema.name, userInfo[schemaName]);
@@ -389,11 +399,21 @@ export const UserProfile: FunctionComponent<UserProfilePropsInterface> = (
} else {
const schemaName:string = schemaNames[0];

if (schema.extended && userInfo[ProfileConstants.SCIM2_ENT_USER_SCHEMA]) {
if (schema.extended && userInfo[ProfileConstants.SCIM2_ENT_USER_SCHEMA]
&& userInfo[ProfileConstants.SCIM2_ENT_USER_SCHEMA][schemaNames[0]]) {
tempProfileInfo.set(
schema.name, userInfo[ProfileConstants.SCIM2_ENT_USER_SCHEMA][schemaName]
schema.name, userInfo[ProfileConstants.SCIM2_ENT_USER_SCHEMA][schemaNames[0]]
);


return;
}

if (schema.extended && userInfo[ProfileConstants.SCIM2_WSO2_USER_SCHEMA]
&& userInfo[ProfileConstants.SCIM2_WSO2_USER_SCHEMA][schemaNames[0]]) {
tempProfileInfo.set(
schema.name, userInfo[ProfileConstants.SCIM2_WSO2_CUSTOM_SCHEMA][schemaNames[0]]
);

return;
}
tempProfileInfo.set(schema.name, userInfo[schemaName]);
@@ -644,7 +664,7 @@ export const UserProfile: FunctionComponent<UserProfilePropsInterface> = (
value: {}
};

if (adminUserType === "internal") {
if (adminUserType === AdminAccountTypes.INTERNAL) {
profileSchema.forEach((schema: ProfileSchemaInterface) => {

if (schema.mutability === ProfileConstants.READONLY_SCHEMA) {
@@ -697,8 +717,12 @@ export const UserProfile: FunctionComponent<UserProfilePropsInterface> = (
} else {
if (schemaNames.length === 1) {
if (schema.extended) {
const schemaId: string = schema?.schemaId
? schema.schemaId
: ProfileConstants.SCIM2_ENT_USER_SCHEMA;

opValue = {
[ProfileConstants.SCIM2_WSO2_USER_SCHEMA]: {
[schemaId]: {
[schemaNames[0]]: schema.type.toUpperCase() === "BOOLEAN" ?
!!values.get(schema.name)?.includes(schema.name) :
values.get(schemaNames[0])
@@ -712,8 +736,12 @@ export const UserProfile: FunctionComponent<UserProfilePropsInterface> = (
}
} else {
if(schema.extended) {
const schemaId: string = schema?.schemaId
? schema.schemaId
: ProfileConstants.SCIM2_ENT_USER_SCHEMA;

opValue = {
[ProfileConstants.SCIM2_WSO2_USER_SCHEMA]: {
[schemaId]: {
[schemaNames[0]]: {
[schemaNames[1]]: schema.type.toUpperCase() === "BOOLEAN" ?
!!values.get(schema.name)?.includes(schema.name) :
@@ -781,7 +809,6 @@ export const UserProfile: FunctionComponent<UserProfilePropsInterface> = (

if (schema.name !== "roles.default") {
if (values.get(schema.name) !== undefined && values.get(schema.name).toString() !== undefined) {

if (ProfileUtils.isMultiValuedSchemaAttribute(profileSchema, schemaNames[0]) ||
schemaNames[0] === "phoneNumbers") {

@@ -821,8 +848,12 @@ export const UserProfile: FunctionComponent<UserProfilePropsInterface> = (
} else {
if (schemaNames.length === 1) {
if (schema.extended) {
const schemaId: string = schema?.schemaId
? schema.schemaId
: ProfileConstants.SCIM2_ENT_USER_SCHEMA;

opValue = {
[ProfileConstants.SCIM2_ENT_USER_SCHEMA]: {
[schemaId]: {
[schemaNames[0]]: schema.type.toUpperCase() === "BOOLEAN" ?
!!values.get(schema.name)?.includes(schema.name) :
values.get(schemaNames[0])
@@ -836,8 +867,12 @@ export const UserProfile: FunctionComponent<UserProfilePropsInterface> = (
}
} else {
if(schema.extended) {
const schemaId: string = schema?.schemaId
? schema.schemaId
: ProfileConstants.SCIM2_ENT_USER_SCHEMA;

opValue = {
[ProfileConstants.SCIM2_ENT_USER_SCHEMA]: {
[schemaId]: {
[schemaNames[0]]: {
[schemaNames[1]]: schema.type.toUpperCase() === "BOOLEAN" ?
!!values.get(schema.name)?.includes(schema.name) :

0 comments on commit bb713a0

Please sign in to comment.