Skip to content

Commit

Permalink
Add role to shelter volunteer
Browse files Browse the repository at this point in the history
  • Loading branch information
peremunoz committed Mar 13, 2024
1 parent ed4918b commit e0cb460
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package cat.udl.eps.softarch.demo.domain;

import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.ManyToOne;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;

import java.util.Collection;

@EqualsAndHashCode(callSuper = true)
@Data
Expand All @@ -13,4 +20,11 @@ public class ShelterVolunteer extends User {
@JsonIdentityReference(alwaysAsId = true)
@ManyToOne
private Shelter userShelter;

@Override
@JsonValue(value = false)
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
public Collection<? extends GrantedAuthority> getAuthorities(){
return AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_SHELTER_VOLUNTEER");
}
}

0 comments on commit e0cb460

Please sign in to comment.