diff --git a/src/users/users.controller.ts b/src/users/users.controller.ts index 4bde1ea1bf7a9f8d264dc36dc3f9360145c78e12..38236989474f2484d521e4aca115d299f84251e7 100644 --- a/src/users/users.controller.ts +++ b/src/users/users.controller.ts @@ -116,4 +116,23 @@ export class UsersController { }); return user; } + + @Post('delete-user') + @ApiResponse({ status: 200, description: 'User deleted' }) + public async deleteUser(@Req() req, @Body() email: { email: string }) { + const user = await this.usersService.deleteOne(email.email); + user.structuresLink.forEach((structureId) => { + this.usersService.isStructureClaimed(structureId.toString()).then((userFound) => { + if (!userFound) { + this.structureService.deleteOne(structureId.toString()); + } + }); + }); + return user; + } + + @Get() + public async getAllUsers(@Req() req) { + return this.usersService.findAll(); + } }