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/CustomOAuth2User.java b/src/main/java/com/gdschongik/gdsc/global/security/CustomOAuth2User.java index e0b689684..69e2c0781 100644 --- a/src/main/java/com/gdschongik/gdsc/global/security/CustomOAuth2User.java +++ b/src/main/java/com/gdschongik/gdsc/global/security/CustomOAuth2User.java @@ -13,14 +13,12 @@ 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(); - } - - public boolean isGuest() { - return memberRole == MemberRole.GUEST; + this.landingStatus = LandingStatus.of(member); } } 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 = 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; + } +}