Skip to content

Commit

Permalink
fix: create new user
Browse files Browse the repository at this point in the history
  • Loading branch information
FredrikOseberg authored and ivarconr committed Jan 11, 2022
1 parent 4409111 commit 5633456
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions src/lib/services/access-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down

0 comments on commit 5633456

Please sign in to comment.