Skip to content

Commit

Permalink
[kbss-cvut/record-manager-ui#202] Remove types from the user
Browse files Browse the repository at this point in the history
  • Loading branch information
palagdan authored and blcham committed Oct 9, 2024
1 parent 500fb8e commit bbf391e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
24 changes: 1 addition & 23 deletions src/main/java/cz/cvut/kbss/study/model/User.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
package cz.cvut.kbss.study.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import cz.cvut.kbss.jopa.model.annotations.CascadeType;
import cz.cvut.kbss.jopa.model.annotations.FetchType;
import cz.cvut.kbss.jopa.model.annotations.Id;
import cz.cvut.kbss.jopa.model.annotations.OWLClass;
import cz.cvut.kbss.jopa.model.annotations.OWLDataProperty;
import cz.cvut.kbss.jopa.model.annotations.OWLObjectProperty;
import cz.cvut.kbss.jopa.model.annotations.ParticipationConstraints;
import cz.cvut.kbss.jopa.model.annotations.Types;
import cz.cvut.kbss.study.model.util.HasDerivableUri;
import cz.cvut.kbss.study.util.Constants;
import cz.cvut.kbss.study.util.IdentificationUtils;
import org.springframework.security.crypto.password.PasswordEncoder;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

@OWLClass(iri = Vocabulary.s_c_Person)
public class User implements HasDerivableUri, Serializable {
Expand Down Expand Up @@ -65,12 +60,8 @@ public class User implements HasDerivableUri, Serializable {
@OWLObjectProperty(iri = Vocabulary.s_p_has_role_group)
private RoleGroup roleGroup;

@Types
private Set<String> types;

public User() {
this.types = new HashSet<>();
types.add(Vocabulary.s_c_doctor_role_group);

}

@Override
Expand Down Expand Up @@ -149,19 +140,6 @@ public void setRoleGroup(RoleGroup roleGroup) {
this.roleGroup = roleGroup;
}

public Set<String> getTypes() {
return types;
}

public void setTypes(Set<String> types) {
this.types = types;
}

public void addType(String type) {
assert types != null;
getTypes().add(type);
}

/**
* Returns true if this user is an admin.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ protected void prePersist(User instance) {
protected void preUpdate(User instance) {
final User currentUser = securityUtils.getCurrentUser();
if (!currentUser.isAdmin()
&& (!instance.getTypes().equals(currentUser.getTypes()) || (instance.getInstitution() != null
&& (!instance.getRoleGroup().getRoles().equals(currentUser.getRoleGroup().getRoles()) || (instance.getInstitution() != null
&& !instance.getInstitution().getKey().equals(currentUser.getInstitution().getKey())))) {
throw new UnauthorizedException("Cannot update user.");
}
Expand Down

0 comments on commit bbf391e

Please sign in to comment.