Skip to content

Commit

Permalink
Merge pull request #790 from woowacourse-teams/fix/#788
Browse files Browse the repository at this point in the history
Fix/#788
  • Loading branch information
ay-eonii authored Oct 25, 2024
2 parents 03b3fac + 60fbf26 commit 22e9ea4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package mouda.backend.auth.business;

import java.util.Optional;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand Down Expand Up @@ -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<Member> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public Member findActiveOrDeletedByIdentifier(String identifier) {
.orElseThrow(() -> new AuthException(HttpStatus.NOT_FOUND, AuthErrorMessage.MEMBER_NOT_FOUND));
}

public Optional<Member> 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));
Expand Down

0 comments on commit 22e9ea4

Please sign in to comment.