Browse Source

added route to manually add an user to db

master
nicolas-arnaud 2 years ago
parent
commit
53b1661064
  1. 12
      back/volume/src/users/users.controller.ts

12
back/volume/src/users/users.controller.ts

@ -131,6 +131,17 @@ export class UsersController {
return await this.usersService.findUser(ftId) 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() @Get()
@UseGuards(AuthenticatedGuard) @UseGuards(AuthenticatedGuard)
async getUser (@FtUser() profile: Profile): Promise<User | null> { async getUser (@FtUser() profile: Profile): Promise<User | null> {
@ -147,4 +158,5 @@ export class UsersController {
return await this.usersService.create(payload) return await this.usersService.create(payload)
} }
} }
} }

Loading…
Cancel
Save