Skip to content

Commit

Permalink
[DEV-89] 회원 탈퇴 시 쿠키가 만료되지 않는 문제 수정 (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
RookieAND authored Jun 12, 2024
1 parent db37421 commit 293e5ec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class AuthService {
private cookieOption = {
secure: true,
sameSite: 'none',
httpOnly: true,
path: '/',
domain: '.dev-malssami.site',
} as const;
Expand Down
15 changes: 13 additions & 2 deletions src/user/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ import {
HttpStatus,
Param,
Patch,
Res,
UseGuards,
} from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';

import type { Response } from 'express';

import { AuthService } from '#/auth/auth.service';
import { AuthenticatedUser } from '#/auth/decorator/auth.decorator';
import { AuthenticationGuard } from '#/auth/guard/auth.guard';
import { ApiDocs } from '#/common/decorators/swagger.decorator';
Expand All @@ -22,7 +26,10 @@ import { UserService } from './user.service';
@ApiTags('User')
@Controller('user')
export class UserController {
constructor(private readonly userService: UserService) {}
constructor(
private readonly userService: UserService,
private readonly authService: AuthService,
) {}

@ApiDocs({
summary: '자기 자신의 유저 정보를 열람합니다',
Expand Down Expand Up @@ -66,7 +73,11 @@ export class UserController {
})
@UseGuards(AuthenticationGuard)
@Delete(':userId')
unregisterUser(@Param('userId') userId: string) {
unregisterUser(
@Param('userId') userId: string,
@Res({ passthrough: true }) response: Response,
) {
this.authService.removeAuthenticateCookie(response);
return this.userService.removeUserInformation(userId);
}

Expand Down

0 comments on commit 293e5ec

Please # to comment.