Skip to content

Commit

Permalink
Merge branch 'feature/SHIBUI-1031' of bitbucket.org:unicon/shib-idp-u…
Browse files Browse the repository at this point in the history
…i into feature/SHIBUI-1031
  • Loading branch information
rmathis committed Jan 7, 2019
2 parents b49469d + 28729c7 commit c723cda
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ ResponseEntity<?> updateOne(@PathVariable(value = "username") String username, @
if (StringUtils.isNotBlank(user.getPassword())) {
persistedUser.setPassword(BCrypt.hashpw(user.getPassword(), BCrypt.gensalt()));
}
userRoleService.updateUserRole(persistedUser);
if (StringUtils.isNotBlank(user.getRole())) {
persistedUser.setRole(user.getRole());
userRoleService.updateUserRole(persistedUser);
}
User savedUser = userRepository.save(persistedUser);
return ResponseEntity.ok(savedUser);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ public class User extends AbstractAuditable {
private Set<Role> roles = new HashSet<>();

public String getRole() {
Set<Role> roles = this.getRoles();
if (roles.size() != 1) {
if (StringUtils.isNotBlank(this.role)) {
return this.role;
if (StringUtils.isBlank(this.role)) {
Set<Role> roles = this.getRoles();
if (roles.size() != 1) {
throw new RuntimeException(String.format("User with username [%s] does not have exactly one role!", this.getUsername()));
}
throw new RuntimeException(String.format("User with username [%s] does not have exactly one role!", this.getUsername()));
this.role = roles.iterator().next().getName();
}
return roles.iterator().next().getName();
return this.role;
}
}

0 comments on commit c723cda

Please sign in to comment.