Fix user granted authority name.
This commit is contained in:
parent
3e08436abd
commit
0ad45adac1
@ -1,5 +0,0 @@
|
||||
package app.mealsmadeeasy.api.user;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface GrantedAuthorityEntityRepository extends JpaRepository<GrantedAuthorityEntity, Long> {}
|
||||
@ -38,7 +38,7 @@ public final class User implements UserDetails {
|
||||
private String password;
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "user")
|
||||
private final Set<GrantedAuthorityEntity> authorities = new HashSet<>();
|
||||
private final Set<UserGrantedAuthority> authorities = new HashSet<>();
|
||||
|
||||
@Column(nullable = false)
|
||||
private Boolean enabled;
|
||||
@ -57,15 +57,15 @@ public final class User implements UserDetails {
|
||||
return this.authorities;
|
||||
}
|
||||
|
||||
public void addAuthority(GrantedAuthorityEntity userGrantedAuthority) {
|
||||
public void addAuthority(UserGrantedAuthority userGrantedAuthority) {
|
||||
this.authorities.add(userGrantedAuthority);
|
||||
}
|
||||
|
||||
public void addAuthorities(Set<? extends GrantedAuthorityEntity> userGrantedAuthorities) {
|
||||
public void addAuthorities(Set<? extends UserGrantedAuthority> userGrantedAuthorities) {
|
||||
userGrantedAuthorities.forEach(this::addAuthority);
|
||||
}
|
||||
|
||||
public void removeAuthority(GrantedAuthorityEntity userGrantedAuthority) {
|
||||
public void removeAuthority(UserGrantedAuthority userGrantedAuthority) {
|
||||
this.authorities.remove(userGrantedAuthority);
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ import org.springframework.security.core.GrantedAuthority;
|
||||
@Entity(name = "UserGrantedAuthority")
|
||||
@Table(name = "user_granted_authority")
|
||||
@Data
|
||||
public final class GrantedAuthorityEntity implements GrantedAuthority {
|
||||
public final class UserGrantedAuthority implements GrantedAuthority {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@ -0,0 +1,5 @@
|
||||
package app.mealsmadeeasy.api.user;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface UserGrantedAuthorityRepository extends JpaRepository<UserGrantedAuthority, Long> {}
|
||||
@ -4,7 +4,7 @@ import java.util.Set;
|
||||
|
||||
public interface UserService {
|
||||
|
||||
User createUser(String username, String email, String rawPassword, Set<GrantedAuthorityEntity> authorities)
|
||||
User createUser(String username, String email, String rawPassword, Set<UserGrantedAuthority> authorities)
|
||||
throws UserCreateException;
|
||||
|
||||
default User createUser(String username, String email, String rawPassword) throws UserCreateException {
|
||||
|
||||
@ -21,7 +21,7 @@ public final class UserServiceImpl implements UserService {
|
||||
String username,
|
||||
String email,
|
||||
String rawPassword,
|
||||
Set<GrantedAuthorityEntity> authorities
|
||||
Set<UserGrantedAuthority> authorities
|
||||
) throws UserCreateException {
|
||||
if (this.userRepository.existsByUsername(username)) {
|
||||
throw new UserCreateException(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user