Skip to content

Commit

Permalink
Feat: 로그아웃 API에 대한 응답 추가
Browse files Browse the repository at this point in the history
- 정상적인 요청 시 204 응답
- 토큰 검사는 JwtAuthGuard에서 진행
- 추후 refresh token이 추가될 것을 고려하여 service 틀 작성
  • Loading branch information
mingxoxo committed Nov 23, 2023
1 parent 03f5214 commit b728ac5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion BE/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { Body, Controller, Post, UseGuards } from "@nestjs/common";
import { Body, Controller, HttpCode, Post, UseGuards } from "@nestjs/common";
import { AuthService } from "./auth.service";
import { AuthCredentialsDto } from "./dto/auth-credential.dto";
import { AccessTokenDto } from "./dto/auth-access-token.dto";
import { NoDuplicateLoginGuard } from "./guard/auth.user-guard";
import { CreateUserDto } from "./dto/users.dto";
import { User } from "./users.entity";
import { GetUser } from "./get-user.decorator";
import { JwtAuthGuard } from "./guard/auth.jwt-guard";

@Controller("auth")
export class AuthController {
Expand All @@ -22,4 +25,11 @@ export class AuthController {
): Promise<AccessTokenDto> {
return this.authService.signIn(authCredentialsDto);
}

@Post("/signout")
@UseGuards(JwtAuthGuard)
@HttpCode(204)
signOut(@GetUser() user: User): void {
this.authService.signOut(user);
}
}
4 changes: 4 additions & 0 deletions BE/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ export class AuthService {
throw new NotFoundException("올바르지 않은 비밀번호입니다.");
}
}

signOut(user: User): void {
// const hasRefreshToken = true;
}
}

0 comments on commit b728ac5

Please sign in to comment.