[permissions] Backfill command to prepare workspaces (#10581)
Closes https://github.com/twentyhq/core-team-issues/issues/317 --------- Co-authored-by: Weiko <corentin@twenty.com>
This commit is contained in:
@ -35,12 +35,16 @@ export class UserRoleService {
|
||||
userWorkspaceId: string;
|
||||
roleId: string;
|
||||
}): Promise<void> {
|
||||
await this.validateAssignRoleInput({
|
||||
const validationResult = await this.validateAssignRoleInput({
|
||||
userWorkspaceId,
|
||||
workspaceId,
|
||||
roleId,
|
||||
});
|
||||
|
||||
if (validationResult?.roleToAssignIsSameAsCurrentRole) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newUserWorkspaceRole = await this.userWorkspaceRoleRepository.save({
|
||||
roleId,
|
||||
userWorkspaceId,
|
||||
@ -209,7 +213,9 @@ export class UserRoleService {
|
||||
const currentRole = roles.get(userWorkspace.id)?.[0];
|
||||
|
||||
if (currentRole?.id === roleId) {
|
||||
return;
|
||||
return {
|
||||
roleToAssignIsSameAsCurrentRole: true,
|
||||
};
|
||||
}
|
||||
|
||||
if (!(currentRole?.label === ADMIN_ROLE_LABEL)) {
|
||||
|
||||
Reference in New Issue
Block a user