From 193af1b475f5f0025c2465db234a2bf3cce63d5a Mon Sep 17 00:00:00 2001 From: sonsumin Date: Sat, 23 Nov 2024 21:18:33 +0900 Subject: [PATCH] =?UTF-8?q?[#2]=E2=9C=A8Feat:=20=ED=86=A0=ED=81=B0=20?= =?UTF-8?q?=EB=B0=9C=EA=B8=89=20=EC=8B=9C=20=EB=A6=AC=ED=94=84=EB=A0=88?= =?UTF-8?q?=EC=8B=9C=20=ED=86=A0=ED=81=B0=20=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/auth/service/impl/AuthServiceImpl.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/univ/yesummit/global/auth/service/impl/AuthServiceImpl.java b/src/main/java/univ/yesummit/global/auth/service/impl/AuthServiceImpl.java index 2eea8fb..2cc828a 100644 --- a/src/main/java/univ/yesummit/global/auth/service/impl/AuthServiceImpl.java +++ b/src/main/java/univ/yesummit/global/auth/service/impl/AuthServiceImpl.java @@ -2,9 +2,13 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import univ.yesummit.domain.member.entity.Member; +import univ.yesummit.domain.member.exception.MemberException; +import univ.yesummit.domain.member.repository.MemberRepository; import univ.yesummit.domain.member.service.MemberService; import univ.yesummit.global.auth.service.AuthService; import univ.yesummit.global.auth.util.JwtUtils; +import univ.yesummit.global.exception.ErrorCode; import java.util.HashMap; import java.util.Map; @@ -16,12 +20,20 @@ public class AuthServiceImpl implements AuthService { private final JwtUtils jwtUtils; private final MemberService memberService; + private final MemberRepository memberRepository; public Map generateTokens(Long userId) { + + Member member = memberRepository.findById(userId) + .orElseThrow(() -> new MemberException(ErrorCode.NOT_FOUND_MEMBER)); + + // JWT 토큰 생성 String accessToken = jwtUtils.createAccessToken(userId); String refreshToken = jwtUtils.createRefreshToken(userId); + member.updateRefreshToken(refreshToken); + // 첫 로그인 여부 확인 boolean isFirstLogin = memberService.isFirstLogin(userId);