|
|
@@ -34,29 +34,19 @@ public class User {
|
|
|
@Email(regexp = "^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+$", message = "Invalid email address")
|
|
|
private String email;
|
|
|
// @NotNull
|
|
|
-// @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
|
|
- private String role;
|
|
|
+ @ManyToMany(fetch = FetchType.EAGER)
|
|
|
+ private Set<Role> role = new HashSet<Role>(0);
|
|
|
@NotNull
|
|
|
private boolean enabled = false;
|
|
|
|
|
|
- public void setRole(String role) {
|
|
|
- this.role = role;
|
|
|
- }
|
|
|
+// public void setRole(String role) {
|
|
|
+// this.role = role;
|
|
|
+// }
|
|
|
|
|
|
public boolean isEnabled() {
|
|
|
return enabled;
|
|
|
}
|
|
|
|
|
|
- public void setEnabled(boolean enabled) {
|
|
|
- this.enabled = enabled;
|
|
|
- }
|
|
|
- // @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
|
|
|
-// private List<Reservation> reservations;
|
|
|
-
|
|
|
-// public void setReservations(Collection<Reservation> reservations) {
|
|
|
-// this.reservations = (List<Reservation>) reservations;
|
|
|
-// }
|
|
|
-
|
|
|
@Override
|
|
|
public String toString() {
|
|
|
return "User{" +
|
|
|
@@ -65,17 +55,36 @@ public class User {
|
|
|
", password='" + password + '\'' +
|
|
|
", email='" + email + '\'' +
|
|
|
", role=" + role +
|
|
|
-// ", reservations=" + reservations +
|
|
|
+ ", enabled=" + enabled +
|
|
|
'}';
|
|
|
}
|
|
|
|
|
|
- public String getRolesForToken() {
|
|
|
- return role;
|
|
|
+ public void setEnabled(boolean enabled) {
|
|
|
+ this.enabled = enabled;
|
|
|
+ }
|
|
|
+ // @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "user")
|
|
|
+// private List<Reservation> reservations;
|
|
|
+
|
|
|
+// public void setReservations(Collection<Reservation> reservations) {
|
|
|
+// this.reservations = (List<Reservation>) reservations;
|
|
|
+// }
|
|
|
+
|
|
|
+ public String[] getRolesForToken() {
|
|
|
+ Set<Role> appUserRoles = getRole(); // Assuming you have a method to retrieve the Set<AppUserRole>
|
|
|
+
|
|
|
+ String[] rolesArray = appUserRoles.stream()
|
|
|
+ .map(Role::getRole)
|
|
|
+ .toArray(String[]::new);
|
|
|
+
|
|
|
+ return rolesArray;
|
|
|
}
|
|
|
|
|
|
public User() {
|
|
|
}
|
|
|
|
|
|
+ public void setRole(Set<Role> role) {
|
|
|
+ this.role = role;
|
|
|
+ }
|
|
|
// public User(Long id, String username, String password, String email, String role) {
|
|
|
// this.id = id;
|
|
|
// this.username = username;
|
|
|
@@ -108,7 +117,7 @@ public class User {
|
|
|
this.email = email;
|
|
|
}
|
|
|
|
|
|
- public String getRole() {
|
|
|
+ public Set<Role> getRole() {
|
|
|
return role;
|
|
|
}
|
|
|
|