From 42e846f273ec5c1cafb109dfc56ce0cbf31319d9 Mon Sep 17 00:00:00 2001 From: uwoobeat Date: Mon, 12 Feb 2024 18:52:25 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=EB=9E=9C=EB=94=A9=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/global/security/LandingStatus.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/com/gdschongik/gdsc/global/security/LandingStatus.java diff --git a/src/main/java/com/gdschongik/gdsc/global/security/LandingStatus.java b/src/main/java/com/gdschongik/gdsc/global/security/LandingStatus.java new file mode 100644 index 000000000..bf91a388b --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/global/security/LandingStatus.java @@ -0,0 +1,27 @@ +package com.gdschongik.gdsc.global.security; + +import com.gdschongik.gdsc.domain.member.domain.Member; +import com.gdschongik.gdsc.domain.member.domain.RequirementStatus; + +public enum LandingStatus { + TO_STUDENT_AUTHENTICATION, // 재학생 인증 페이지로 랜딩 + TO_REGISTRATION, // 가입신청 페이지로 랜딩 + TO_DASHBOARD, // 대시보드로 랜딩 + ; + + public static LandingStatus of(Member member) { + // 아직 재학생 인증을 하지 않았다면 재학생 인증 페이지로 랜딩 + if (member.getRequirement().getUnivStatus() == RequirementStatus.PENDING) { + return TO_STUDENT_AUTHENTICATION; + } + + // 재학생 인증은 했지만 가입신청을 하지 않았다면 가입신청 페이지로 랜딩 + // 가입신청 여부는 학번 존재여부로 판단 + if (member.getStudentId() == null) { + return TO_REGISTRATION; + } + + // 재학생 인증과 가입신청을 모두 완료했다면 대시보드로 랜딩 + return TO_DASHBOARD; + } +} From f06fedde43c06a46dd5268665d624d59bb0d2fb4 Mon Sep 17 00:00:00 2001 From: uwoobeat Date: Mon, 12 Feb 2024 18:53:08 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20oauth2=20=EC=9D=B8=EC=A6=9D?= =?UTF-8?q?=EC=A3=BC=EC=B2=B4=EC=97=90=20=EB=9E=9C=EB=94=A9=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gdschongik/gdsc/global/security/CustomOAuth2User.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gdschongik/gdsc/global/security/CustomOAuth2User.java b/src/main/java/com/gdschongik/gdsc/global/security/CustomOAuth2User.java index e0b689684..1ae2ab647 100644 --- a/src/main/java/com/gdschongik/gdsc/global/security/CustomOAuth2User.java +++ b/src/main/java/com/gdschongik/gdsc/global/security/CustomOAuth2User.java @@ -13,11 +13,13 @@ public class CustomOAuth2User extends DefaultOAuth2User { private final Long memberId; private final MemberRole memberRole; + private final LandingStatus landingStatus; public CustomOAuth2User(OAuth2User oAuth2User, Member member) { super(oAuth2User.getAuthorities(), oAuth2User.getAttributes(), GITHUB_NAME_ATTR_KEY); this.memberId = member.getId(); this.memberRole = member.getRole(); + this.landingStatus = LandingStatus.of(member); } public boolean isGuest() { From e1d4f16dea04ad85d350ea4b8e3a71f5ba4a2d3c Mon Sep 17 00:00:00 2001 From: uwoobeat Date: Mon, 12 Feb 2024 18:53:23 +0900 Subject: [PATCH 3/4] =?UTF-8?q?refactor:=20=EB=AF=B8=EC=82=AC=EC=9A=A9=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gdschongik/gdsc/global/security/CustomOAuth2User.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/global/security/CustomOAuth2User.java b/src/main/java/com/gdschongik/gdsc/global/security/CustomOAuth2User.java index 1ae2ab647..69e2c0781 100644 --- a/src/main/java/com/gdschongik/gdsc/global/security/CustomOAuth2User.java +++ b/src/main/java/com/gdschongik/gdsc/global/security/CustomOAuth2User.java @@ -21,8 +21,4 @@ public CustomOAuth2User(OAuth2User oAuth2User, Member member) { this.memberRole = member.getRole(); this.landingStatus = LandingStatus.of(member); } - - public boolean isGuest() { - return memberRole == MemberRole.GUEST; - } } From 96ea5e97af5cb00633833a35438d518ed355e76e Mon Sep 17 00:00:00 2001 From: uwoobeat Date: Mon, 12 Feb 2024 18:53:44 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20=EC=86=8C=EC=85=9C=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EC=9D=91=EB=8B=B5=20=ED=97=A4=EB=8D=94?= =?UTF-8?q?=EC=97=90=20=EB=9E=9C=EB=94=A9=EC=83=81=ED=83=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/global/common/constant/SecurityConstant.java | 2 +- .../gdschongik/gdsc/global/security/CustomSuccessHandler.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/global/common/constant/SecurityConstant.java b/src/main/java/com/gdschongik/gdsc/global/common/constant/SecurityConstant.java index 5ff2d1820..52da9c9be 100644 --- a/src/main/java/com/gdschongik/gdsc/global/common/constant/SecurityConstant.java +++ b/src/main/java/com/gdschongik/gdsc/global/common/constant/SecurityConstant.java @@ -2,7 +2,7 @@ public class SecurityConstant { - public static final String REGISTRATION_REQUIRED_HEADER = "Registration-Required"; + public static final String LANDING_STATUS_HEADER = "Landing-Status"; public static final String TOKEN_ROLE_NAME = "role"; public static final String GITHUB_NAME_ATTR_KEY = "id"; public static final String ACCESS_TOKEN_HEADER_PREFIX = "Bearer "; diff --git a/src/main/java/com/gdschongik/gdsc/global/security/CustomSuccessHandler.java b/src/main/java/com/gdschongik/gdsc/global/security/CustomSuccessHandler.java index 9a4f4e7b6..4533e0e1e 100644 --- a/src/main/java/com/gdschongik/gdsc/global/security/CustomSuccessHandler.java +++ b/src/main/java/com/gdschongik/gdsc/global/security/CustomSuccessHandler.java @@ -28,8 +28,8 @@ public void onAuthenticationSuccess( CustomOAuth2User oAuth2User = (CustomOAuth2User) authentication.getPrincipal(); - // 게스트 유저이면 회원가입 필요하므로 헤더 설정 - response.setHeader(REGISTRATION_REQUIRED_HEADER, oAuth2User.isGuest() ? "true" : "false"); + // 랜딩 페이지 결정에 필요한 정보를 헤더에 추가 + response.setHeader(LANDING_STATUS_HEADER, oAuth2User.getLandingStatus().name()); // 토큰 생성 후 쿠키에 저장 AccessTokenDto accessTokenDto =