Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CB-5295 set enable flag on create user #2940

Merged
merged 6 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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