Skip to content

Commit

Permalink
fix: v2.1에서 인증 예외코드 에러 사항을 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
stophwan committed Aug 25, 2024
1 parent d545dc1 commit dadfbac
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ public Authentication authenticate(Authentication authentication) throws Authent

private Authentication processAuthentication(JwtAuthenticationToken authenticationToken) {
User user = findUserUseCase.findUserByAuthId(String.valueOf(authenticationToken.getPrincipal()));
try {
user.matchPassword(passwordEncoder, String.valueOf(authenticationToken.getCredentials()));
return new JwtAuthenticationToken(
user.getId(), null, Collections.singleton(new SimpleGrantedAuthority("ROLE_USER"))
);
} catch (IllegalArgumentException e) {
String userPassword = String.valueOf(authenticationToken.getCredentials());
if(!user.matchPassword(passwordEncoder, userPassword)) {
throw new UnAuthorizedException(INCORRECT_PASSWORD.toString());
}
return new JwtAuthenticationToken(
user.getId(), null, Collections.singleton(new SimpleGrantedAuthority("ROLE_USER"))
);
}

}

0 comments on commit dadfbac

Please sign in to comment.