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 8e73286 commit 4ccee49
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,32 @@
import java.util.Collection;

public class MemberDetails implements UserDetails {
private Member member;
private final String username;
private final String password;
private final String role;

public MemberDetails(Member member) {
this.member = member;
username = member.getEmail();
password = member.getPassword();
role = member.getRole().toString();
}

@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
/* --- 회원의 역할(role)은 하나만 받을 수 있음 --- */
Collection<SimpleGrantedAuthority> authorities = new ArrayList<>();
authorities.add(new SimpleGrantedAuthority(member.getRole().toString()));
authorities.add(new SimpleGrantedAuthority(role));
return authorities;
}

@Override
public String getPassword() {
return member.getPassword();
return username;
}

@Override
public String getUsername() {
return member.getEmail();
return password;
}

@Override
Expand Down

0 comments on commit 4ccee49

Please sign in to comment.