File tree Expand file tree Collapse file tree 2 files changed +5
-7
lines changed
src/controllers/user-management Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -66,8 +66,8 @@ export class NewKombitCreationController {
6666 ) ;
6767
6868 if ( ! dbUser . email ) {
69- // The desired email is already in use for another user (this will throw an error in the database)
70- if ( this . userService . isEmailUsedByAUser ( dto . email ) ) {
69+ // The desired email is already in use for another user (this would also throw an error in the database)
70+ if ( await this . userService . isEmailUsedByAUser ( dto . email ) ) {
7171 throw new BadRequestException ( ErrorCodes . EmailAlreadyInUse ) ;
7272 }
7373
Original file line number Diff line number Diff line change @@ -129,12 +129,10 @@ export class UserController {
129129 try {
130130 // Verify that we have admin access to the user and that the user is on an organization
131131 const dbUser = await this . userService . findOneWithOrganizations ( id ) ;
132- if ( ! dbUser . permissions || dbUser . permissions . length < 1 ) {
133- throw new ForbiddenException ( ) ;
134- }
135132
136- // Has to be admin for at least one organization containing the user
137- if ( ! dbUser . permissions . some ( perm => req . user . permissions . hasUserAdminOnOrganization ( perm . organization . id ) ) ) {
133+ // Requesting user has to be admin for at least one organization containing the user
134+ // _OR_ be global admin
135+ if ( ! req . user . permissions . isGlobalAdmin && ! dbUser . permissions . some ( perm => req . user . permissions . hasUserAdminOnOrganization ( perm . organization . id ) ) ) {
138136 throw new ForbiddenException ( ) ;
139137 }
140138
You can’t perform that action at this time.
0 commit comments