diff --git a/backend/src/main/java/mouda/backend/auth/business/GoogleAuthService.java b/backend/src/main/java/mouda/backend/auth/business/GoogleAuthService.java index 0511a7ae..54dafe11 100644 --- a/backend/src/main/java/mouda/backend/auth/business/GoogleAuthService.java +++ b/backend/src/main/java/mouda/backend/auth/business/GoogleAuthService.java @@ -1,5 +1,7 @@ package mouda.backend.auth.business; +import java.util.Optional; + import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -28,9 +30,10 @@ public class GoogleAuthService { public LoginResponse login(GoogleLoginRequest request) { String name = userInfoProvider.getName(request.idToken()); String identifier = userInfoProvider.getIdentifier(request.idToken()); - Member member = memberFinder.findActiveOrDeletedByIdentifier(identifier); + Optional optionalMember = memberFinder.findOptionalActiveOrDeletedByIdentifier(identifier); - if (member != null) { + if (optionalMember.isPresent()) { + Member member = optionalMember.get(); joinManager.rejoin(member); memberWriter.updateName(member.getId(), name); return new LoginResponse(accessTokenProvider.provide(member), member.isConverted()); diff --git a/backend/src/main/java/mouda/backend/member/implement/MemberFinder.java b/backend/src/main/java/mouda/backend/member/implement/MemberFinder.java index 3547ba27..712b74fe 100644 --- a/backend/src/main/java/mouda/backend/member/implement/MemberFinder.java +++ b/backend/src/main/java/mouda/backend/member/implement/MemberFinder.java @@ -26,6 +26,10 @@ public Member findActiveOrDeletedByIdentifier(String identifier) { .orElseThrow(() -> new AuthException(HttpStatus.NOT_FOUND, AuthErrorMessage.MEMBER_NOT_FOUND)); } + public Optional findOptionalActiveOrDeletedByIdentifier(String identifier) { + return memberRepository.findActiveOrDeletedByIdentifier(identifier); + } + public Member findByMemberId(long memberId) { return memberRepository.findById(memberId) .orElseThrow(() -> new AuthException(HttpStatus.NOT_FOUND, AuthErrorMessage.MEMBER_NOT_FOUND));