[로그아웃 기능 구현현]
This commit is contained in:
@@ -21,6 +21,8 @@ import io.swagger.v3.oas.annotations.media.Content;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import com.bio.bio_backend.global.constants.ApiResponseCode;
|
import com.bio.bio_backend.global.constants.ApiResponseCode;
|
||||||
import com.bio.bio_backend.global.annotation.LogExecution;
|
import com.bio.bio_backend.global.annotation.LogExecution;
|
||||||
|
import com.bio.bio_backend.global.utils.SecurityUtils;
|
||||||
|
|
||||||
|
|
||||||
@Tag(name = "Member", description = "회원 관련 API")
|
@Tag(name = "Member", description = "회원 관련 API")
|
||||||
@RestController
|
@RestController
|
||||||
@@ -55,12 +57,12 @@ public class MemberController {
|
|||||||
@ApiResponse(responseCode = "401", description = "인증 실패", content = @Content(schema = @Schema(implementation = ApiResponseDto.class)))
|
@ApiResponse(responseCode = "401", description = "인증 실패", content = @Content(schema = @Schema(implementation = ApiResponseDto.class)))
|
||||||
})
|
})
|
||||||
@PostMapping("/logout")
|
@PostMapping("/logout")
|
||||||
public ResponseEntity<ApiResponseDto<Void>> logout(@RequestHeader("Authorization") String authorization) {
|
public ResponseEntity<ApiResponseDto<Void>> logout() {
|
||||||
try {
|
try {
|
||||||
// Authorization 헤더에서 토큰 추출
|
String userId = SecurityUtils.getCurrentUserId();
|
||||||
String token = authorization.replace("Bearer ", "");
|
memberService.deleteRefreshToken(userId);
|
||||||
// Refresh Token 삭제 (실제로는 JWT 블랙리스트나 DB에서 삭제)
|
|
||||||
// memberService.deleteRefreshToken(userId);
|
log.info("사용자 로그아웃 완료: {}", userId);
|
||||||
|
|
||||||
return ResponseEntity.ok(ApiResponseDto.success(ApiResponseCode.COMMON_SUCCESS));
|
return ResponseEntity.ok(ApiResponseDto.success(ApiResponseCode.COMMON_SUCCESS));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Reference in New Issue
Block a user