Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[DEV-89] 회원 탈퇴 시 쿠키가 만료되지 않는 문제 수정 #41

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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