From 5e051945c2f86d9b96ce6842e6d42d9247a98654 Mon Sep 17 00:00:00 2001 From: sonsumin Date: Fri, 22 Nov 2024 17:01:21 +0900 Subject: [PATCH] =?UTF-8?q?[#2]=F0=9F=90=9BFix:=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EC=9C=A0=EB=AC=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/controller/AuthController.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/univ/yesummit/global/auth/controller/AuthController.java b/src/main/java/univ/yesummit/global/auth/controller/AuthController.java index 4180dda..796522b 100644 --- a/src/main/java/univ/yesummit/global/auth/controller/AuthController.java +++ b/src/main/java/univ/yesummit/global/auth/controller/AuthController.java @@ -1,11 +1,18 @@ package univ.yesummit.global.auth.controller; import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpSession; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.view.RedirectView; + +import java.util.HashMap; +import java.util.Map; + @RestController @RequestMapping("/v1/api/kakao") public class AuthController { @@ -15,4 +22,18 @@ public class AuthController { public RedirectView login() { return new RedirectView("/oauth2/authorization/kakao"); } -} + + @GetMapping("/status") + @Operation(summary = "로그인 상태 확인", description = "사용자의 로그인 상태를 확인합니다.") + public ResponseEntity> getLoginStatus(HttpServletRequest request) { + // 쿠키 또는 세션에서 로그인 상태를 확인 + HttpSession session = request.getSession(false); // 세션이 없으면 null 반환 + boolean loggedIn = session != null && session.getAttribute("user") != null; + + // 응답 데이터 생성 + Map response = new HashMap<>(); + response.put("loggedIn", loggedIn); + + return ResponseEntity.ok(response); + } +} \ No newline at end of file