Skip to content

Commit

Permalink
Merge pull request #188 from Funssion-SWM/user
Browse files Browse the repository at this point in the history
fix: 일반로그인 계정으로 구글로그인시 redirect-2
  • Loading branch information
goathoon authored Nov 14, 2023
2 parents f68d208 + caa33b9 commit 8295611
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpStatus;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
Expand All @@ -32,6 +31,7 @@ public class AuthenticationSuccessHandler extends SavedRequestAwareAuthenticatio
@Value("${jwt.domain}") private String domain;
@Value("${oauth-signup-uri}") private String signUpURI;
@Value("${oauth-signin-uri}") private String signInURI;
@Value("${oauth-login-uri}") private String loginURI;

@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
Expand All @@ -51,9 +51,7 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo

resolveResponseCookieByOrigin(request, response, accessToken, refreshToken);
response.sendRedirect(redirectUriByFirstJoinOrNot(authentication));
if (authentication.getAuthorities().stream().filter(o->o.getAuthority().equals(Role.EXCEPTION.getRoles())).findAny().isPresent()){
response.sendError(HttpStatus.SC_CONFLICT,"같은 이메일로 등록된 일반 계정이 존재합니다.");
}

}

private static void makeSuccessResponseBody(HttpServletResponse response) throws IOException {
Expand Down Expand Up @@ -117,6 +115,10 @@ public String getRedirectUri(Authentication authentication) {
.build().toString();

}
else if (authorities.stream().filter(o->o.getAuthority().equals(Role.EXCEPTION.getRoles())).findAny().isPresent()){
return UriComponentsBuilder.fromHttpUrl(loginURI)
.build().toString();
}
else{ // non social 로그인의 경우 회원가입한 유저이므로 else문으로 항상 들어감.
return UriComponentsBuilder.fromHttpUrl(signInURI)
.build().toString();
Expand Down

0 comments on commit 8295611

Please sign in to comment.