Skip to content

Commit

Permalink
리펙토링 : MemberDetails에서 Member 엔티티 의존성 제거
Browse files Browse the repository at this point in the history
MemberDetails에서 필드로 있었던 Member 엔티티를 Username, Password, Role로 나눈 후에 생성자에서 초기화 하는 것으로 변경
  • Loading branch information
jaycobcoder committed Aug 4, 2023
1 parent ff6613d commit 8e73286
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@ public class ReadingBooksAuthenticationProvider implements AuthenticationProvide

@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
/* --- 아이디 관련 검증(UserDetailsService) --- */
String email = authentication.getName();
UserDetails memberDetails = memberDetailsService.loadUserByUsername(email);

/* --- 비밀번호 관련 검증(PasswordEncoder) --- */
String credential = matchPassword(authentication, memberDetails);
return new UsernamePasswordAuthenticationToken(email, credential, memberDetails.getAuthorities());
}

private String matchPassword(Authentication authentication, UserDetails memberDetails) {
String rawPassword = authentication.getCredentials().toString();
String hashPassword = memberDetails.getPassword();
checkPassword(rawPassword, hashPassword);

return new UsernamePasswordAuthenticationToken(email, rawPassword, memberDetails.getAuthorities());
return rawPassword;
}

private void checkPassword(String rawPassword, String hashPassword) {
Expand Down

0 comments on commit 8e73286

Please sign in to comment.