Commit d38cf10e authored by Matija Obreza's avatar Matija Obreza
Browse files

Updates to VETTEDUSER

parent 3a5c576f
......@@ -217,5 +217,14 @@ public class User extends BusinessModel {
// We don't support password expiration
return false;
}
public boolean hasRole(String roleName) {
for (UserRole userRole : getRoles()) {
if (userRole.getName().equalsIgnoreCase(roleName)) {
return true;
}
}
return false;
}
}
......@@ -350,6 +350,7 @@ public class UserServiceImpl implements UserService {
}
@Override
@Transactional
public void addVettedUserRole(String uuid){
User user = userPersistence.findByUuid(uuid);
Set<UserRole> userRoles = user.getRoles();
......
......@@ -80,12 +80,12 @@ public class UserProfileController extends BaseController {
return "/user/index";
}
@RequestMapping("/{uuid:.+}/addRoleVettedUser")
@PreAuthorize("hasRole('ADMINISTRATOR')")
public String addRoleVettedUser(@PathVariable("uuid")String uuid){
userService.addVettedUserRole(uuid);
return "redirect:/profile/list";
}
@RequestMapping("/{uuid:.+}/vetted-user")
@PreAuthorize("hasRole('ADMINISTRATOR')")
public String addRoleVettedUser(@PathVariable("uuid") String uuid) {
userService.addVettedUserRole(uuid);
return "redirect:/profile/" + uuid;
}
@RequestMapping("/{uuid:.+}")
@PreAuthorize("isAuthenticated()")
......@@ -154,7 +154,6 @@ public class UserProfileController extends BaseController {
return "redirect:/content/user.password-reset-email-sent";
}
@RequestMapping(value = "/{tokenUuid:.+}/pwdreset", method = RequestMethod.GET)
public String passwordReset(ModelMap model, @PathVariable("tokenUuid") String tokenUuid) {
......@@ -165,7 +164,7 @@ public class UserProfileController extends BaseController {
@RequestMapping(value = "/{tokenUuid:.+}/pwdreset", method = RequestMethod.POST)
public String updatePassword(ModelMap model, @PathVariable("tokenUuid") String tokenUuid, @RequestParam(value = "key", required = true) String key,
@RequestParam("password") String password) throws UserException {
if (emailVerificationService.changePassword(tokenUuid, key, password)) {
return "redirect:/content/user.password-reset";
} else {
......
......@@ -107,6 +107,7 @@ user.email=E-mail Address
user.account-status=Account Status
user.account-disabled=Account disabled
user.account-locked-until=Account locked until
user.roles=User roles
userprofile.page.title=User profile
userprofile.update.title=Update your profile
......
......@@ -28,7 +28,6 @@
<c:if test="${not user.enabled}">DISABLED</c:if>
<c:if test="${user.accountLocked}">LOCKED</c:if>
</td>
<td><a href="<c:url value="/profile/${user.uuid}/addRoleVettedUser"/> "class="btn btn-default"/>VETTED USER</td>
</tr>
</c:forEach>
</table>
......
......@@ -37,6 +37,15 @@
</c:if>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label"><spring:message code="user.roles" /></label>
<div class="col-lg-5">
<c:forEach items="${user.roles}" var="role">
${role}
</c:forEach>
</div>
</div>
</security:authorize>
......@@ -61,8 +70,15 @@
<security:authorize access="hasRole('ADMINISTRATOR') || (isAuthenticated() && principal.user.id == #user.id)">
<a href="<c:url value="/management/user/${user.uuid}/tokens" />" class="btn btn-default"><spring:message code="oauth-client.issued.tokens" /></a>
</security:authorize>
<security:authorize access="(not hasRole('VALIDATEDUSER') && principal.user.id == #user.id)">
<security:authorize access="hasRole('ADMINISTRATOR') || principal.user.id == #user.id">
<c:if test="${not user.hasRole('VALIDATEDUSER')}">
<a href="<c:url value="/profile/${user.uuid}/send"/>" class="btn btn-default"/>Send validation email</a>
</c:if>
</security:authorize>
<security:authorize access="hasRole('ADMINISTRATOR')">
<c:if test="${not user.hasRole('VETTEDUSER')}">
<a href="<c:url value="/profile/${user.uuid}/vetted-user"/> "class="btn btn-default"/>Vetted user</a>
</c:if>
</security:authorize>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment