Fix user granted authority name.

This commit is contained in:
Jesse Brault 2026-01-15 14:34:22 -06:00
parent 3e08436abd
commit 0ad45adac1
6 changed files with 12 additions and 12 deletions

View File

@ -1,5 +0,0 @@
package app.mealsmadeeasy.api.user;
import org.springframework.data.jpa.repository.JpaRepository;
public interface GrantedAuthorityEntityRepository extends JpaRepository<GrantedAuthorityEntity, Long> {}

View File

@ -38,7 +38,7 @@ public final class User implements UserDetails {
private String password; private String password;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "user") @OneToMany(fetch = FetchType.EAGER, mappedBy = "user")
private final Set<GrantedAuthorityEntity> authorities = new HashSet<>(); private final Set<UserGrantedAuthority> authorities = new HashSet<>();
@Column(nullable = false) @Column(nullable = false)
private Boolean enabled; private Boolean enabled;
@ -57,15 +57,15 @@ public final class User implements UserDetails {
return this.authorities; return this.authorities;
} }
public void addAuthority(GrantedAuthorityEntity userGrantedAuthority) { public void addAuthority(UserGrantedAuthority userGrantedAuthority) {
this.authorities.add(userGrantedAuthority); this.authorities.add(userGrantedAuthority);
} }
public void addAuthorities(Set<? extends GrantedAuthorityEntity> userGrantedAuthorities) { public void addAuthorities(Set<? extends UserGrantedAuthority> userGrantedAuthorities) {
userGrantedAuthorities.forEach(this::addAuthority); userGrantedAuthorities.forEach(this::addAuthority);
} }
public void removeAuthority(GrantedAuthorityEntity userGrantedAuthority) { public void removeAuthority(UserGrantedAuthority userGrantedAuthority) {
this.authorities.remove(userGrantedAuthority); this.authorities.remove(userGrantedAuthority);
} }

View File

@ -7,7 +7,7 @@ import org.springframework.security.core.GrantedAuthority;
@Entity(name = "UserGrantedAuthority") @Entity(name = "UserGrantedAuthority")
@Table(name = "user_granted_authority") @Table(name = "user_granted_authority")
@Data @Data
public final class GrantedAuthorityEntity implements GrantedAuthority { public final class UserGrantedAuthority implements GrantedAuthority {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)

View File

@ -0,0 +1,5 @@
package app.mealsmadeeasy.api.user;
import org.springframework.data.jpa.repository.JpaRepository;
public interface UserGrantedAuthorityRepository extends JpaRepository<UserGrantedAuthority, Long> {}

View File

@ -4,7 +4,7 @@ import java.util.Set;
public interface UserService { 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; throws UserCreateException;
default User createUser(String username, String email, String rawPassword) throws UserCreateException { default User createUser(String username, String email, String rawPassword) throws UserCreateException {

View File

@ -21,7 +21,7 @@ public final class UserServiceImpl implements UserService {
String username, String username,
String email, String email,
String rawPassword, String rawPassword,
Set<GrantedAuthorityEntity> authorities Set<UserGrantedAuthority> authorities
) throws UserCreateException { ) throws UserCreateException {
if (this.userRepository.existsByUsername(username)) { if (this.userRepository.existsByUsername(username)) {
throw new UserCreateException( throw new UserCreateException(