Skip to content

Commit

Permalink
[BE-76] feat: 로그아웃
Browse files Browse the repository at this point in the history
[BE-76] feat: 로그아웃
  • Loading branch information
BlackBean99 authored Mar 5, 2024
2 parents 68e31b5 + 97b47fd commit 69c33b0
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Recruit-Domain/HELP.md
.gradle
.gradle/**
server/.gradle/**
server/.gradle
.server/.gradle/**
.server/.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
Expand Down
Binary file removed server/.gradle/7.6.1/checksums/checksums.lock
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file removed server/.gradle/7.6.1/fileChanges/last-build.bin
Binary file not shown.
Binary file removed server/.gradle/7.6.1/fileHashes/fileHashes.bin
Binary file not shown.
Binary file removed server/.gradle/7.6.1/fileHashes/fileHashes.lock
Binary file not shown.
Binary file not shown.
Empty file removed server/.gradle/7.6.1/gc.properties
Empty file.
Binary file modified server/.gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.econovation.recruit.api.user.controller;

import static com.econovation.recruitcommon.consts.RecruitStatic.INTERVIEWER_SUCCESS_SIGNUP_MESSAGE;
import static com.econovation.recruitcommon.consts.RecruitStatic.PASSWORD_SUCCESS_CHANGE_MESSAGE;
import static com.econovation.recruitcommon.consts.RecruitStatic.*;

import com.econovation.recruit.api.interviewer.docs.InterviewerExceptionDocs;
import com.econovation.recruit.api.user.usecase.UserLoginUseCase;
Expand Down Expand Up @@ -69,6 +68,17 @@ public ResponseEntity<TokenResponse> login(
return new ResponseEntity<>(tokenResponse, HttpStatus.OK);
}

@Operation(summary = "로그아웃 합니다.", description = "Maxage가 0인 쿠키를 보내 로그아웃 합니다.")
@PostMapping("/logout")
public ResponseEntity<String> logout(HttpServletResponse response) {
response.addHeader(
"Set-Cookie", SecurityUtils.logoutCookie("refreshToken", null).toString());
response.addHeader(
"Set-Cookie", SecurityUtils.logoutCookie("accessToken", null).toString());

return new ResponseEntity<>(LOGOUT_SUCCESS_MESSAGE, HttpStatus.OK);
}

@Operation(summary = "회원가입합니다.", description = "회원가입합니다.")
@ApiErrorExceptionsExample(InterviewerExceptionDocs.class)
@PostMapping("/signup")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,14 @@ public static ResponseCookie setCookie(String name, String value) {
.path("/")
.build();
}

public static ResponseCookie logoutCookie(String name, String value) {
return ResponseCookie.from(name, value)
.secure(true)
.sameSite("None")
.httpOnly(true)
.maxAge(0)
.path("/")
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public class RecruitStatic {
public static final String WORK_CARD_SUCCESS_UPDATE_MESSAGE = "성공적으로 업무카드가 수정됐습니다";
public static final List<String> TIMETABLE_APPLICANT_FIELD = List.of("field", "name");

public static final String LOGOUT_SUCCESS_MESSAGE = "성공적으로 로그아웃 됐습니다";

public static final String[] SwaggerPatterns = {
"/swagger-resources/**",
"/swagger-ui/**",
Expand Down

0 comments on commit 69c33b0

Please sign in to comment.