Commit 2e4550b1 authored by Matija Obreza's avatar Matija Obreza
Browse files

AuthUserDetails was removed, security principal is instance of User

parent b7c2fadb
......@@ -81,6 +81,7 @@ public class UserServiceImpl extends BasicUserServiceImpl<UserRole, User> implem
}
@Override
@Transactional
public User createUser(String email, String fullName, String password, AccountType accountType) throws NotUniqueUserException, PasswordPolicyException {
LOG.info("Creating user email={} fullName={}", email, fullName);
final User user = new User();
......@@ -92,7 +93,8 @@ public class UserServiceImpl extends BasicUserServiceImpl<UserRole, User> implem
return userRepository.save(user);
}
@Transactional(readOnly = false)
@Transactional
@Override
public UserDetails getUserDetails(User user) {
if (user == null) {
......@@ -234,7 +236,7 @@ public class UserServiceImpl extends BasicUserServiceImpl<UserRole, User> implem
}
@Override
@Transactional(readOnly = false)
@Transactional
@PreAuthorize("hasRole('ADMINISTRATOR')")
public void setAccountActive(String uuid, boolean enabled) {
final User user = userRepository.findByUuid(uuid);
......
......@@ -62,7 +62,7 @@ public class UserProfileController extends BaseController {
@RequestMapping("/")
public String list(ModelMap model, @RequestParam(value = "page", defaultValue = "1") int page) {
model.addAttribute("pagedData", userService.listUsers(new PageRequest(page - 1, 50, new Sort("name"))));
model.addAttribute("pagedData", userService.listUsers(new PageRequest(page - 1, 50, new Sort("fullName"))));
return VIEWBASE + "index";
}
......
......@@ -180,11 +180,11 @@
<security:authorize access="isAuthenticated()">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> <spring:message code="user.pulldown.heading"
arguments="${user.user.name}" /> <span class="caret"></span>
arguments="${user.fullName}" /> <span class="caret"></span>
</a>
<ul class="dropdown-menu pull-left">
<li>
<a href="<c:url value="/profile/${user.username}" />"> <spring:message code="user.pulldown.profile" />
<a href="<c:url value="/profile/${user.uuid}" />"> <spring:message code="user.pulldown.profile" />
</a>
</li>
<li>
......
......@@ -16,7 +16,7 @@
<div class="form-group">
<label for="name" class="col-lg-2 control-label"><spring:message code="registration.full-name" /></label>
<div class="col-lg-3">
<input type="text" id="name" name="name" class="span3 form-control" value="${user.name}" />
<input type="text" id="name" name="name" class="span3 form-control" value="${user.fullName}" />
</div>
</div>
<div class="form-group">
......
......@@ -20,7 +20,7 @@
<tr>
<td class="col-xs-5"><c:if test="${not user.systemAccount}">
<a href="<c:url value="/admin/users/${user.uuid}" />"><c:out
value="${user.name}" /></a>
value="${user.fullName}" /></a>
</c:if></td>
<td class="col-xs-2"><c:if test="${user.systemAccount}">SYSTEM</c:if>
<c:if test="${not user.enabled}">DISABLED</c:if> <c:if
......
......@@ -7,17 +7,17 @@
<title><spring:message code="userprofile.page.title" /></title>
</head>
<body>
<security:authorize access="hasRole('ADMINISTRATOR') || (isAuthenticated() && principal.user.id == #user.id)">
<security:authorize access="hasRole('ADMINISTRATOR') || (isAuthenticated() && principal.id == #user.id)">
<a href="<c:url value="/admin/users/${user.uuid}/edit" />" class="close"> <spring:message code="edit" /></a>
</security:authorize>
<div class="form-horizontal">
<div class="form-group">
<label for="password" class="col-lg-2 control-label"><spring:message code="user.full-name" /></label>
<div class="col-lg-5 form-control-static"><c:out value="${user.name}" /></div>
<div class="col-lg-5 form-control-static"><c:out value="${user.fullName}" /></div>
</div>
<security:authorize access="hasRole('ADMINISTRATOR') || (isAuthenticated() && principal.user.id == #user.id)">
<security:authorize access="hasRole('ADMINISTRATOR') || (isAuthenticated() && principal.id == #user.id)">
<div class="form-group">
<label for="password" class="col-lg-2 control-label"><spring:message code="user.email" /></label>
<div class="col-lg-5 form-control-static"><c:out value="${user.email}" /></div>
......@@ -60,10 +60,10 @@
</security:authorize>
<div class="form-group">
<security:authorize access="hasRole('ADMINISTRATOR') || (isAuthenticated() && principal.user.id == #user.id)">
<security:authorize access="hasRole('ADMINISTRATOR') || (isAuthenticated() && principal.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="hasRole('ADMINISTRATOR') || principal.user.id == #user.id">
<security:authorize access="hasRole('ADMINISTRATOR') || principal.id == #user.id">
<c:if test="${not user.hasRole('VALIDATEDUSER')}">
<a href="<c:url value="/admin/users/${user.uuid}/send"/>" class="btn btn-default"/>Send validation email</a>
</c:if>
......@@ -81,7 +81,7 @@
<c:forEach items="${teams}" var="team" varStatus="status">
<li class="${status.count % 2 == 0 ? 'even' : 'odd'}"><a href="<c:url value="/team/${team.uuid}" />"><c:out value="${team.name}" /></a>
<security:authorize access="isAuthenticated() && principal.user.id == #user.id">
<security:authorize access="isAuthenticated() && principal.id == #user.id">
<a x-team-id="${team.id}" class="pull-right"><spring:message code="team.leave-team" /></a>
</security:authorize>
</li>
......@@ -95,7 +95,7 @@
</div>
</div>
<!--End modal-->
<security:authorize access="isAuthenticated() && principal.user.id == #user.id">
<security:authorize access="isAuthenticated() && principal.id == #user.id">
<h4><spring:message code="team.create-new-team" /></h4>
<form id="new-team-form" class="form-horizontal">
<div class="form-group">
......@@ -117,7 +117,7 @@
<security:authorize access="principal.user.id == #user.id">
<security:authorize access="principal.id == #user.id">
$("#new-team-form input[type=submit]").on("click", function(e) {
e.preventDefault();
x01("<c:url value="/json/v0/me/teams" />", { success: function(e) {
......
......@@ -21,7 +21,7 @@
<spring:message code="oauth2.confirm-request" />
</h1>
<p>
<spring:message code="oauth2.confirm-client" arguments="${user.user.name},${client.title}" htmlEscape="false" />
<spring:message code="oauth2.confirm-client" arguments="${user.fullName},${client.title}" htmlEscape="false" />
</p>
<c:if test="${client.description ne null and client.description.length()>0}">
......
......@@ -79,14 +79,14 @@
</div>
</div>
<div class="form-group">
<form:label for="name" cssClass="col-lg-2 col-md-3 col-sm-3 col-xs-12 control-label" path="name">
<form:label for="name" cssClass="col-lg-2 col-md-3 col-sm-3 col-xs-12 control-label" path="fullName">
<spring:message code="registration.full-name" />
</form:label>
<div class="col-lg-10 col-md-9 col-sm-9 col-xs-12">
<form:input id="name" name="name" cssClass="span3 required form-control" path="name"/>
<form:input id="name" name="name" cssClass="span3 required form-control" path="fullName"/>
</div>
<div class="col-lg-offset-2 col-lg-4 col-md-offset-3 col-md-4 col-sm-offset-3 col-sm-4 col-xs-12">
<spring:bind path="name">
<spring:bind path="fullName">
<c:if test="${status.error}">
<gui:alert type="danger">
<spring:message code="${status.errorMessage}" />
......
......@@ -24,7 +24,7 @@
<ul class="funny-list">
<c:forEach items="${teammembers}" var="user" varStatus="status">
<li class="${status.count % 2 == 0 ? 'even' : 'odd'}">
<c:out value="${user.name}" />
<c:out value="${user.fullName}" />
<security:authorize access="hasRole('ADMINISTRATOR')">
<a href="<c:url value="/team/${team.uuid}/${user.uuid}/deleteMember"/> "><spring:message code="delete"/></a>
</security:authorize>
......
......@@ -20,7 +20,7 @@
<div class="form-group">
<label for="name" class="col-lg-2 control-label"><spring:message code="registration.full-name" /></label>
<div class="col-lg-3">
<form:input id="name" name="name" class="span3 form-control" path="user.name" />
<form:input id="name" name="name" class="span3 form-control" path="user.fullName" />
</div>
</div>
<div class="form-group">
......@@ -30,7 +30,7 @@
</div>
</div>
<c:if test="${user.loginType eq 'PASSWORD'}">
<c:if test="${user.accountType eq 'LOCAL'}">
<div class="form-group">
<label for="currentPassword" class="col-lg-2 control-label"><spring:message code="registration.current-password" /></label>
<div class="col-lg-3">
......
......@@ -20,7 +20,7 @@
<table class="funny-list">
<c:forEach items="${pagedData.content}" var="user" varStatus="status">
<tr class="clearfix ${status.count % 2 == 0 ? 'even' : 'odd'}">
<td><c:if test="${not user.systemAccount}"><a href="<c:url value="/profile/${user.uuid}" />"><c:out value="${user.name}" /></a></c:if></td>
<td><c:if test="${not user.systemAccount}"><a href="<c:url value="/profile/${user.uuid}" />"><c:out value="${user.fullName}" /></a></c:if></td>
<td><c:out value="${user.uuid}" /></td>
<td><c:out value="${user.email}" /></td>
<td>
......
......@@ -9,17 +9,17 @@
<body>
<cms:informative-h1 title="userprofile.page.title" fancy="true" info="userprofile.page.intro" />
<security:authorize access="hasRole('ADMINISTRATOR') || (isAuthenticated() && principal.user.id == #user.id)">
<security:authorize access="hasRole('ADMINISTRATOR') || (isAuthenticated() && principal.id == #user.id)">
<a href="<c:url value="/profile/${user.uuid}/edit" />" class="close"> <spring:message code="edit" /></a>
</security:authorize>
<div class="form-horizontal">
<div class="form-group">
<label for="password" class="col-lg-2 control-label"><spring:message code="user.full-name" /></label>
<div class="col-lg-5 form-control-static"><c:out value="${user.name}" /></div>
<div class="col-lg-5 form-control-static"><c:out value="${user.fullName}" /></div>
</div>
<security:authorize access="hasRole('ADMINISTRATOR') || (isAuthenticated() && principal.user.id == #user.id)">
<security:authorize access="hasRole('ADMINISTRATOR') || (isAuthenticated() && principal.id == #user.id)">
<div class="form-group">
<label for="password" class="col-lg-2 control-label"><spring:message code="user.email" /></label>
<div class="col-lg-5 form-control-static"><c:out value="${user.email}" /></div>
......@@ -38,7 +38,7 @@
<div class="form-group">
<label class="col-lg-2 control-label"><spring:message code="user.login-type" /></label>
<div class="col-lg-5 form-control-static"><c:out value="${user.loginType}" /></div>
<div class="col-lg-5 form-control-static"><c:out value="${user.accountType}" /></div>
</div>
<div class="form-group">
......@@ -67,13 +67,13 @@
</security:authorize>
<div class="form-group">
<security:authorize access="hasRole('ADMINISTRATOR') && (isAuthenticated() && principal.user.id == #user.id)">
<security:authorize access="hasRole('ADMINISTRATOR') && (isAuthenticated() && principal.id == #user.id)">
<a href="<c:url value="/management/allTokens" />" class="btn btn-default"> <spring:message code="oauth-client.list" /></a>
</security:authorize>
<security:authorize access="hasRole('ADMINISTRATOR') || (isAuthenticated() && principal.user.id == #user.id)">
<security:authorize access="hasRole('ADMINISTRATOR') || (isAuthenticated() && principal.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="hasRole('ADMINISTRATOR') || principal.user.id == #user.id">
<security:authorize access="hasRole('ADMINISTRATOR') || principal.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>
......@@ -97,7 +97,7 @@
<c:forEach items="${teams}" var="team" varStatus="status">
<li class="${status.count % 2 == 0 ? 'even' : 'odd'}"><a href="<c:url value="/team/${team.uuid}" />"><c:out value="${team.name}" /></a>
<security:authorize access="isAuthenticated() && principal.user.id == #user.id">
<security:authorize access="isAuthenticated() && principal.id == #user.id">
<a x-team-id="${team.id}" class="pull-right"><spring:message code="team.leave-team" /></a>
</security:authorize>
</li>
......@@ -111,7 +111,7 @@
</div>
</div>
<!--End modal-->
<security:authorize access="isAuthenticated() && principal.user.id == #user.id">
<security:authorize access="isAuthenticated() && principal.id == #user.id">
<h4><spring:message code="team.create-new-team" /></h4>
<form id="new-team-form" class="form-horizontal">
<div class="form-group">
......@@ -133,7 +133,7 @@
<security:authorize access="principal.user.id == #user.id">
<security:authorize access="principal.id == #user.id">
$("#new-team-form input[type=submit]").on("click", function(e) {
e.preventDefault();
x01("<c:url value="/json/v0/me/teams" />", { success: function(e) {
......
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