From 53b1661064a74182610c8725935dc3fac4e52767 Mon Sep 17 00:00:00 2001 From: nicolas-arnaud Date: Sun, 5 Mar 2023 16:23:43 +0100 Subject: [PATCH] added route to manually add an user to db --- back/volume/src/users/users.controller.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/back/volume/src/users/users.controller.ts b/back/volume/src/users/users.controller.ts index a11b0ab..47c57fb 100644 --- a/back/volume/src/users/users.controller.ts +++ b/back/volume/src/users/users.controller.ts @@ -131,6 +131,17 @@ export class UsersController { return await this.usersService.findUser(ftId) } + @Post(":id") + @UseGuards(AuthenticatedGuard) + async createById (@Body() payload: UserDto) { + const user = await this.usersService.findUser(payload.ftId) + if (user != null) { + return await this.usersService.update(user, payload) + } else { + return await this.usersService.create(payload) + } + } + @Get() @UseGuards(AuthenticatedGuard) async getUser (@FtUser() profile: Profile): Promise { @@ -147,4 +158,5 @@ export class UsersController { return await this.usersService.create(payload) } } + }