1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-08-18 13:48:58 +02:00

fix: Add back to get permissions working for editor role

This commit is contained in:
sighphyre 2021-12-15 12:32:46 +02:00 committed by Ivar Conradi Østhus
parent 0634758784
commit cd782be6dc
No known key found for this signature in database
GPG Key ID: 31AC596886B0BD09

View File

@ -152,11 +152,31 @@ export class AccessService {
userId,
RoleType.ROOT,
);
await this.store.addUserToRole(
userId,
newRootRole.id,
ALL_PROJECTS,
const editorRole = await this.store.getRoleByName(
RoleName.EDITOR,
);
if (newRootRole.id === editorRole.id) {
const viewerRole = await this.store.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}`,