1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-19 00:15:43 +01:00

fix: create new user

This commit is contained in:
Fredrik Oseberg 2022-01-04 11:06:51 +01:00 committed by Ivar Conradi Østhus
parent 4409111be0
commit 563345695d
No known key found for this signature in database
GPG Key ID: 31AC596886B0BD09

View File

@ -195,30 +195,11 @@ export class AccessService {
RoleType.ROOT,
);
const editorRole = await this.roleStore.getRoleByName(
RoleName.EDITOR,
await this.store.addUserToRole(
userId,
newRootRole.id,
ALL_PROJECTS,
);
if (newRootRole.id === editorRole.id) {
const viewerRole = await this.roleStore.getRoleByName(
RoleName.VIEWER,
);
await this.store.addUserToRole(
userId,
editorRole.id,
'default',
);
await this.store.addUserToRole(
userId,
viewerRole.id,
ALL_PROJECTS,
);
} else {
await this.store.addUserToRole(
userId,
newRootRole.id,
ALL_PROJECTS,
);
}
} catch (error) {
throw new Error(
`Could not add role=${newRootRole.name} to userId=${userId}`,