From e717cdcae246e7af56e9602a23c3390807e6097b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20PAILHAREY?= <rpailharey@grandlyon.com> Date: Thu, 8 Sep 2022 13:20:37 +0000 Subject: [PATCH] feat(profile): logged in users can access the profile of other users --- src/users/controllers/users.controller.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/users/controllers/users.controller.ts b/src/users/controllers/users.controller.ts index 2e6eabdad..7a4d242e7 100644 --- a/src/users/controllers/users.controller.ts +++ b/src/users/controllers/users.controller.ts @@ -197,7 +197,11 @@ export class UsersController { @Get(':id') @ApiParam({ name: 'id', type: String, required: true }) public async getUser(@Param() params): Promise<IUser> { - return this.usersService.findById(params.id); + const user = await this.usersService.findById(params.id); + if (!user) { + throw new HttpException('User does not exist', HttpStatus.NOT_FOUND); + } + return user; } @ApiResponse({ status: HttpStatus.CREATED, description: 'Description updated' }) -- GitLab