Skip to content

Commit

Permalink
Create Student entity role fix
Browse files Browse the repository at this point in the history
  • Loading branch information
PauBarahona22 committed Oct 9, 2024
1 parent 6dedc4c commit 0875a3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/main/java/cat/udl/eps/softarch/demo/domain/Student.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
Expand All @@ -21,5 +22,9 @@ public class Student extends User {

@NotEmpty
private String name;

@Override
@ElementCollection
public Collection<GrantedAuthority> getAuthorities(){
return AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_CLIENT");
}
}
3 changes: 0 additions & 3 deletions src/main/java/cat/udl/eps/softarch/demo/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ public void encodePassword() {
@JsonValue(value = false)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
public Collection<? extends GrantedAuthority> getAuthorities() {
if (this instanceof Student) {
return AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_STUDENT");
}
return AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_USER");
}

Expand Down

0 comments on commit 0875a3c

Please sign in to comment.