Skip to content

Commit

Permalink
#34 [Update] 로그아웃 기능 구현 완료
Browse files Browse the repository at this point in the history
서버에서 refresh token을 지워줌으로써 Access token을 재발급받지 못하게 하고, 프론트에서 Access token을 삭제해주면 로그아웃 완료
  • Loading branch information
Anna-Jin committed Jul 18, 2022
1 parent e99e1eb commit d517890
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.mpnp.baechelin.user.controller;

import com.mpnp.baechelin.login.oauth.common.AuthResponse;
import com.mpnp.baechelin.user.service.UserService;
import io.swagger.annotations.ApiOperation;
import com.mpnp.baechelin.util.CookieUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.User;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/user")
Expand All @@ -17,7 +19,8 @@ public class UserController {
private final UserService userService;

@RequestMapping("/logout")
public ResponseEntity<String> logout(@AuthenticationPrincipal User user) {
return null;
public ResponseEntity<String> logout(HttpServletRequest request, HttpServletResponse response) {
CookieUtil.deleteCookie(request, response, "refresh_token");
return new ResponseEntity<>("로그아웃 완료", HttpStatus.OK);
}
}

0 comments on commit d517890

Please sign in to comment.