|
20 | 20 | import { AppState } from "@wso2is/admin.core.v1/store";
|
21 | 21 | import { userConfig } from "@wso2is/admin.extensions.v1";
|
22 | 22 | import { administratorConfig } from "@wso2is/admin.extensions.v1/configs/administrator";
|
| 23 | +import { SCIMConfigInterface } from "@wso2is/admin.extensions.v1/configs/models/scim"; |
23 | 24 | import { SCIMConfigs } from "@wso2is/admin.extensions.v1/configs/scim";
|
24 | 25 | import { userstoresConfig } from "@wso2is/admin.extensions.v1/configs/userstores";
|
25 | 26 | import { updateGroupDetails, useGroupList } from "@wso2is/admin.groups.v1/api/groups";
|
@@ -67,8 +68,8 @@ import {
|
67 | 68 | EmailsInterface,
|
68 | 69 | PayloadInterface,
|
69 | 70 | UserDetailsInterface,
|
70 |
| - WizardStepInterface, |
71 |
| - createEmptyUserDetails } from "../../models/user"; |
| 71 | + WizardStepInterface |
| 72 | +} from "../../models/user"; |
72 | 73 | import { generatePassword, getConfiguration, getUsernameConfiguration } from "../../utils";
|
73 | 74 |
|
74 | 75 | interface AddUserWizardPropsInterface extends IdentifiableComponentInterface, TestableComponentInterface {
|
@@ -459,68 +460,46 @@ export const AddUserWizard: FunctionComponent<AddUserWizardPropsInterface> = (
|
459 | 460 | username = userInfo.domain + "/" + userInfo.userName;
|
460 | 461 | }
|
461 | 462 |
|
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 | + |
463 | 478 | const password: string = userInfo.newPassword;
|
464 | 479 |
|
465 | 480 | // Users who get invited offline are also considered as password-based users.
|
466 | 481 | // They will be assigned a randomly generated temporary password.
|
467 | 482 | // Temporary password can be changed via the offline invite link.
|
468 | 483 | 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; |
484 | 485 | } 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(); |
500 | 487 | } 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" |
517 | 490 | };
|
518 | 491 | }
|
519 | 492 |
|
520 | 493 | if (isAttributeProfileForUserCreationEnabled) {
|
| 494 | + const mergedSCIMSchema: SCIMConfigInterface = { |
| 495 | + ...userDetails[SCIMConfigs.scim.systemSchema], |
| 496 | + ...userInfo[SCIMConfigs.scim.systemSchema] |
| 497 | + }; |
| 498 | + |
521 | 499 | const combinedUserDetails: UserDetailsInterface = omit({
|
522 | 500 | ...userInfo,
|
523 |
| - ...userDetails |
| 501 | + ...userDetails, |
| 502 | + [SCIMConfigs.scim.systemSchema]: mergedSCIMSchema |
524 | 503 | }, "passwordOption", "newPassword", "userType", "domain", "firstName", "lastName");
|
525 | 504 |
|
526 | 505 | // If email value is not present, use the emails value.
|
|
0 commit comments