Skip to content

Commit c800e90

Browse files
Fix bug in invite flow
1 parent 001984f commit c800e90

File tree

2 files changed

+31
-52
lines changed

2 files changed

+31
-52
lines changed

features/admin.users.v1/components/wizard/add-user-wizard.tsx

+29-50
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import { AppState } from "@wso2is/admin.core.v1/store";
2121
import { userConfig } from "@wso2is/admin.extensions.v1";
2222
import { administratorConfig } from "@wso2is/admin.extensions.v1/configs/administrator";
23+
import { SCIMConfigInterface } from "@wso2is/admin.extensions.v1/configs/models/scim";
2324
import { SCIMConfigs } from "@wso2is/admin.extensions.v1/configs/scim";
2425
import { userstoresConfig } from "@wso2is/admin.extensions.v1/configs/userstores";
2526
import { updateGroupDetails, useGroupList } from "@wso2is/admin.groups.v1/api/groups";
@@ -67,8 +68,8 @@ import {
6768
EmailsInterface,
6869
PayloadInterface,
6970
UserDetailsInterface,
70-
WizardStepInterface,
71-
createEmptyUserDetails } from "../../models/user";
71+
WizardStepInterface
72+
} from "../../models/user";
7273
import { generatePassword, getConfiguration, getUsernameConfiguration } from "../../utils";
7374

7475
interface AddUserWizardPropsInterface extends IdentifiableComponentInterface, TestableComponentInterface {
@@ -459,68 +460,46 @@ export const AddUserWizard: FunctionComponent<AddUserWizardPropsInterface> = (
459460
username = userInfo.domain + "/" + userInfo.userName;
460461
}
461462

462-
let userDetails: UserDetailsInterface = createEmptyUserDetails();
463+
let userDetails: UserDetailsInterface = {
464+
emails: [
465+
{
466+
primary: true,
467+
value: userInfo.email
468+
}
469+
],
470+
name: {
471+
familyName: userInfo.lastName,
472+
givenName: userInfo.firstName
473+
},
474+
profileUrl: userInfo.profileUrl,
475+
userName: username
476+
};
477+
463478
const password: string = userInfo.newPassword;
464479

465480
// Users who get invited offline are also considered as password-based users.
466481
// They will be assigned a randomly generated temporary password.
467482
// Temporary password can be changed via the offline invite link.
468483
if (askPasswordFromUser) {
469-
userDetails = {
470-
emails: [
471-
{
472-
primary: true,
473-
value: userInfo.email
474-
}
475-
],
476-
name: {
477-
familyName: userInfo.lastName,
478-
givenName: userInfo.firstName
479-
},
480-
password: password,
481-
profileUrl: userInfo.profileUrl,
482-
userName: username
483-
};
484+
userDetails.password = password;
484485
} else if (isOfflineUser) {
485-
userDetails = {
486-
emails: [
487-
{
488-
primary: true,
489-
value: userInfo.email
490-
}
491-
],
492-
name: {
493-
familyName: userInfo.lastName,
494-
givenName: userInfo.firstName
495-
},
496-
password: generateRandomPassword(),
497-
profileUrl: userInfo.profileUrl,
498-
userName: username
499-
};
486+
userDetails.password = generateRandomPassword();
500487
} else {
501-
userDetails = {
502-
emails: [
503-
{
504-
primary: true,
505-
value: userInfo.email
506-
}
507-
],
508-
name: {
509-
familyName: userInfo.lastName,
510-
givenName: userInfo.firstName
511-
},
512-
profileUrl: userInfo.profileUrl,
513-
[ SCIMConfigs.scim.systemSchema ]: {
514-
askPassword: "true"
515-
},
516-
userName: username
488+
userDetails[ SCIMConfigs.scim.systemSchema ] = {
489+
askPassword: "true"
517490
};
518491
}
519492

520493
if (isAttributeProfileForUserCreationEnabled) {
494+
const mergedSCIMSchema: SCIMConfigInterface = {
495+
...userDetails[SCIMConfigs.scim.systemSchema],
496+
...userInfo[SCIMConfigs.scim.systemSchema]
497+
};
498+
521499
const combinedUserDetails: UserDetailsInterface = omit({
522500
...userInfo,
523-
...userDetails
501+
...userDetails,
502+
[SCIMConfigs.scim.systemSchema]: mergedSCIMSchema
524503
}, "passwordOption", "newPassword", "userType", "domain", "firstName", "lastName");
525504

526505
// If email value is not present, use the emails value.

features/admin.users.v1/components/wizard/steps/add-user-basic.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ export const AddUserUpdated: React.FunctionComponent<AddUserProps> = (
196196
}
197197
}, []);
198198

199-
const countryList: DropdownItemProps[] = CommonUtils.getCountryList();
200-
201199
const isDistinctAttributeProfilesDisabled: boolean = featureConfig?.attributeDialects?.disabledFeatures?.includes(
202200
ClaimManagementConstants.DISTINCT_ATTRIBUTE_PROFILES_FEATURE_FLAG
203201
);
@@ -258,6 +256,8 @@ export const AddUserUpdated: React.FunctionComponent<AddUserProps> = (
258256
userStore
259257
);
260258

259+
const countryList: DropdownItemProps[] = useMemo(() => CommonUtils.getCountryList(), []);
260+
261261
const userStoreUsernameRegEx: string = useMemo(() => {
262262
if (originalUserStore) {
263263
return originalUserStore?.properties?.find(

0 commit comments

Comments
 (0)