Skip to content

Commit

Permalink
CB-5295 set enable flag on create user (#2940)
Browse files Browse the repository at this point in the history
Co-authored-by: Evgenia Bezborodova <[email protected]>
  • Loading branch information
Wroud and EvgeniaBzzz authored Sep 30, 2024
1 parent 34c6e6c commit bb9a62d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions webapp/packages/core-authentication/src/UsersResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const UsersResourceNewUsers = resourceKeyListAlias('@users-resource/new-u
interface UserCreateOptions {
userId: string;
authRole?: string;
enabled?: boolean;
}

@injectable()
Expand Down Expand Up @@ -137,11 +138,11 @@ export class UsersResource extends CachedMapResource<string, AdminUser, UserReso
});
}

async create({ userId, authRole }: UserCreateOptions): Promise<AdminUser> {
async create({ userId, authRole, enabled }: UserCreateOptions): Promise<AdminUser> {
const { user } = await this.graphQLService.sdk.createUser({
userId,
authRole,
enabled: false,
enabled: enabled ?? false,
...this.getIncludesMap(userId),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class UserFormInfoPart extends FormPart<IUserFormInfoState, IUserFormStat
const user = await this.usersResource.create({
userId: this.state.userId,
authRole: getTransformedAuthRole(this.state.authRole),
enabled: this.state.enabled,
});
this.initialState.userId = user.userId;
this.formState.setMode(FormMode.Edit);
Expand All @@ -105,7 +106,9 @@ export class UserFormInfoPart extends FormPart<IUserFormInfoState, IUserFormStat
await this.updateCredentials();
await this.updateTeams();
await this.updateAuthRole(); // we must update role before enabling user to prevent situation when user current role will reach the limit
await this.updateStatus();
if (this.formState.mode === FormMode.Edit) {
await this.updateStatus();
}
await this.updateMetaParameters();

this.usersResource.markOutdated(this.state.userId);
Expand Down

0 comments on commit bb9a62d

Please sign in to comment.