Skip to content

Commit

Permalink
fix: Oauth 로그인 탈퇴 여부
Browse files Browse the repository at this point in the history
  • Loading branch information
Darren4641 committed Oct 29, 2023
1 parent 479f1bf commit a3e44d6
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ else if(member.getAccountStatus().equals(AccountStatus.DISABLED.getStatus()))
public Message getOauthSuiteToken(String accessToken, String userAgent, PasswordEncoder passwordEncoder) {
ReqSignInMemberDto reqSignInMemberDto = googleAuth.getGoogleMemberInfo(accessToken);

Optional<Token> token = memberRepository.findByEmail(reqSignInMemberDto.getEmail()).map(member -> verifyOauthAccount(reqSignInMemberDto, userAgent, passwordEncoder));
Optional<Token> token = memberRepository.findByEmail(reqSignInMemberDto.getEmail()).map(member -> verifyOauthAccount(reqSignInMemberDto, passwordEncoder));
return token.map(suiteToken -> new Message(StatusCode.OK, suiteToken)).orElseGet(() -> new Message(StatusCode.CREATED, reqSignInMemberDto));
}

public Message getAppleOauthSuiteToken(String accessToken, String userAgent, PasswordEncoder passwordEncoder) {
ReqSignInMemberDto reqSignInMemberDto = appleAuth.getAppleMemberInfo(accessToken);

Optional<Token> token = memberRepository.findByEmail(reqSignInMemberDto.getEmail()).map(member -> verifyOauthAccount(reqSignInMemberDto, userAgent, passwordEncoder));
Optional<Token> token = memberRepository.findByEmail(reqSignInMemberDto.getEmail()).map(member -> verifyOauthAccount(reqSignInMemberDto, passwordEncoder));
return token.map(suiteToken -> new Message(StatusCode.OK, suiteToken)).orElseGet(() -> new Message(StatusCode.CREATED, reqSignInMemberDto));
}

Expand Down Expand Up @@ -191,11 +191,15 @@ public void lookupPassordByPhoneNumber(String email, String newPassword) {
member.updatePassword(newPassword);
}

private Token verifyOauthAccount(ReqSignInMemberDto reqSignInMemberDto, String userAgent, PasswordEncoder passwordEncoder) {
private Token verifyOauthAccount(ReqSignInMemberDto reqSignInMemberDto, PasswordEncoder passwordEncoder) {
Member member = memberRepository.findByEmail(reqSignInMemberDto.getEmail()).orElseThrow(() -> new CustomException(StatusCode.USERNAME_NOT_FOUND));

if(!passwordEncoder.matches(reqSignInMemberDto.getPassword(), member.getPassword()))
throw new CustomException(StatusCode.REGISTERED_EMAIL);
else if(member.getAccountStatus().equals(AccountStatus.DORMANT.getStatus()))
throw new CustomException(StatusCode.DORMANT_ACCOUNT);
else if(member.getAccountStatus().equals(AccountStatus.DISABLED.getStatus()))
throw new CustomException(StatusCode.DISABLED_ACCOUNT);

Token token = jwtCreator.createToken(member);

Expand Down

0 comments on commit a3e44d6

Please sign in to comment.