Skip to content

Commit

Permalink
fix: frontend error when user deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
stonith404 committed Mar 4, 2023
1 parent fddad3e commit 0317f3a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion backend/src/user/user.controller.ts
Expand Up @@ -6,9 +6,11 @@ import {
Param,
Patch,
Post,
Res,
UseGuards,
} from "@nestjs/common";
import { User } from "@prisma/client";
import { Response } from "express";
import { GetUser } from "src/auth/decorator/getUser.decorator";
import { AdministratorGuard } from "src/auth/guard/isAdmin.guard";
import { JwtGuard } from "src/auth/guard/jwt.guard";
Expand Down Expand Up @@ -40,7 +42,16 @@ export class UserController {

@Delete("me")
@UseGuards(JwtGuard)
async deleteCurrentUser(@GetUser() user: User) {
async deleteCurrentUser(
@GetUser() user: User,
@Res({ passthrough: true }) response: Response
) {
response.cookie("access_token", "accessToken", { maxAge: -1 });
response.cookie("refresh_token", "", {
path: "/api/auth/token",
httpOnly: true,
maxAge: -1,
});
return new UserDTO().from(await this.userService.delete(user.id));
}

Expand Down

0 comments on commit 0317f3a

Please sign in to comment.