Skip to content
Snippets Groups Projects

328 admin gestion des utilisateurs eviter que le premier item de la liste soit selectionne quand on

Files
3
@@ -285,6 +285,25 @@ export class AdminController {
return this.usersService.findById(setUserJob.userId);
}
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles('admin')
@ApiBearerAuth('JWT')
@ApiOperation({ description: 'Remove user job' })
@ApiResponse({ status: HttpStatus.OK, description: 'Return user profile' })
@ApiResponse({ status: HttpStatus.BAD_REQUEST, description: 'User does not exist' })
@Put('removeUserJob')
public async removeUserJob(@Body() removeUserJob): Promise<IUser> {
this.logger.debug(`removeUserJob`);
const userDocument = await this.usersService.findById(removeUserJob.userId);
if (!userDocument) {
this.logger.warn(`User does not exist: ${removeUserJob.userId}`);
throw new HttpException('User does not exist', HttpStatus.BAD_REQUEST);
}
await this.usersService.removeUserJob(userDocument._id);
return this.usersService.findById(removeUserJob.userId);
}
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles('admin')
@ApiBearerAuth('JWT')
@@ -310,6 +329,24 @@ export class AdminController {
return this.usersService.findById(setUserEmployer.userId);
}
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles('admin')
@ApiBearerAuth('JWT')
@ApiOperation({ description: 'Remove user employer' })
@ApiResponse({ status: HttpStatus.OK, description: 'Return user profile' })
@ApiResponse({ status: HttpStatus.BAD_REQUEST, description: 'User does not exist' })
@Put('removeUserEmployer')
public async removeUserEmployer(@Body() removeUserEmployer): Promise<IUser> {
this.logger.debug(`removeUserEmployer`);
const userDocument = await this.usersService.findById(removeUserEmployer.userId);
if (!userDocument) {
this.logger.warn(`User does not exist: ${removeUserEmployer.userId}`);
throw new HttpException('User does not exist', HttpStatus.BAD_REQUEST);
}
await this.usersService.removeUserEmployer(userDocument._id);
return this.usersService.findById(removeUserEmployer.userId);
}
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles('admin')
@ApiBearerAuth('JWT')
Loading