@@ -33,7 +33,11 @@ import { CreateUserDto } from "@dto/user-management/create-user.dto";
3333import { UpdateUserDto } from "@dto/user-management/update-user.dto" ;
3434import { UserResponseDto } from "@dto/user-response.dto" ;
3535import { ErrorCodes } from "@entities/enum/error-codes.enum" ;
36- import { checkIfUserIsGlobalAdmin , checkIfUserHasAccessToOrganization , OrganizationAccessScope } from "@helpers/security-helper" ;
36+ import {
37+ checkIfUserIsGlobalAdmin ,
38+ checkIfUserHasAccessToOrganization ,
39+ OrganizationAccessScope ,
40+ } from "@helpers/security-helper" ;
3741import { UserService } from "@services/user-management/user.service" ;
3842import { ListAllUsersResponseDto } from "@dto/list-all-users-response.dto" ;
3943import { ListAllUsersMinimalResponseDto } from "@dto/list-all-users-minimal-response.dto" ;
@@ -56,7 +60,7 @@ export class UserController {
5660 constructor (
5761 private userService : UserService ,
5862 private organizationService : OrganizationService
59- ) { }
63+ ) { }
6064
6165 private readonly logger = new Logger ( UserController . name ) ;
6266
@@ -111,7 +115,11 @@ export class UserController {
111115 @Req ( ) req : AuthenticatedRequest ,
112116 @Body ( ) body : RejectUserDto
113117 ) : Promise < Organization > {
114- checkIfUserHasAccessToOrganization ( req , body . orgId , OrganizationAccessScope . UserAdministrationWrite ) ;
118+ checkIfUserHasAccessToOrganization (
119+ req ,
120+ body . orgId ,
121+ OrganizationAccessScope . UserAdministrationWrite
122+ ) ;
115123
116124 const user = await this . userService . findOne ( body . userIdToReject ) ;
117125 const organization = await this . organizationService . findByIdWithUsers ( body . orgId ) ;
@@ -130,17 +138,22 @@ export class UserController {
130138 // Verify that we have admin access to the user and that the user is on an organization
131139 const dbUser = await this . userService . findOneWithOrganizations ( id ) ;
132140
133- // Requesting user has to be admin for at least one organization containing the user
141+ // Requesting user has to be admin for at least one organization containing the user
134142 // _OR_ be global admin
135- if ( ! req . user . permissions . isGlobalAdmin && ! dbUser . permissions . some ( perm => req . user . permissions . hasUserAdminOnOrganization ( perm . organization . id ) ) ) {
143+ if (
144+ ! req . user . permissions . isGlobalAdmin &&
145+ ! dbUser . permissions . some ( perm =>
146+ req . user . permissions . hasUserAdminOnOrganization ( perm . organization . id )
147+ )
148+ ) {
136149 throw new ForbiddenException ( ) ;
137- }
138-
150+ }
151+
139152 // Only a global admin can modify a global admin user
140153 if ( dto . globalAdmin ) {
141154 checkIfUserIsGlobalAdmin ( req ) ;
142155 }
143-
156+
144157 // Don't leak the passwordHash
145158 const { passwordHash : _ , ...user } = await this . userService . updateUser (
146159 id ,
@@ -176,7 +189,7 @@ export class UserController {
176189 req . user . username
177190 ) ;
178191
179- return wasOk
192+ return wasOk ;
180193 }
181194
182195 @Get ( "/awaitingUsers" )
@@ -232,7 +245,6 @@ export class UserController {
232245 // Don't leak the passwordHash
233246 const { passwordHash : _ , ...user } = await this . userService . findOne (
234247 id ,
235- getExtendedInfo ,
236248 getExtendedInfo
237249 ) ;
238250
@@ -243,7 +255,10 @@ export class UserController {
243255 }
244256
245257 @Get ( "organizationUsers/:organizationId" )
246- @ApiOperation ( { summary : "Get all users for an organization. Requires UserAdmin priviledges for the specified organization" } )
258+ @ApiOperation ( {
259+ summary :
260+ "Get all users for an organization. Requires UserAdmin priviledges for the specified organization" ,
261+ } )
247262 async findByOrganizationId (
248263 @Req ( ) req : AuthenticatedRequest ,
249264 @Param ( "organizationId" , new ParseIntPipe ( ) ) organizationId : number ,
@@ -252,7 +267,9 @@ export class UserController {
252267 try {
253268 // Check if user has access to organization
254269 if ( ! req . user . permissions . hasUserAdminOnOrganization ( organizationId ) ) {
255- throw new ForbiddenException ( "User does not have org admin permissions for this organization" ) ;
270+ throw new ForbiddenException (
271+ "User does not have org admin permissions for this organization"
272+ ) ;
256273 }
257274
258275 // Get user objects
0 commit comments