1
0
mirror of https://github.com/stonith404/pingvin-share.git synced 2024-11-04 23:10:13 +01:00

fix: frontend error when user deleted

This commit is contained in:
Elias Schneider 2023-03-04 23:40:02 +01:00
parent fddad3ef70
commit 0317f3a508
No known key found for this signature in database
GPG Key ID: 07E623B294202B6C

View File

@ -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";
@ -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));
}