Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Backend
Commits
3a5c576f
Commit
3a5c576f
authored
Jan 31, 2014
by
igoshin
Committed by
Matija Obreza
Feb 04, 2014
Browse files
Final version of user story "Add role VETTEDUSER"
#10509
parent
0c6b6ed4
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys2/server/model/UserRole.java
View file @
3a5c576f
...
...
@@ -18,7 +18,7 @@ package org.genesys2.server.model;
public
enum
UserRole
{
USER
(
"User"
),
ADMINISTRATOR
(
"Administrator"
),
ORGANIZATION_ADMINISTRATOR
(
"Organization Administrator"
),
NETWORK_ADMINISTRATOR
(
"Network Administrator"
),
VALIDATEDUSER
(
"Validated user"
);
"Validated
user"
),
VETTEDUSER
(
"Vetted
user"
);
String
label
;
...
...
src/main/java/org/genesys2/server/service/UserService.java
View file @
3a5c576f
...
...
@@ -71,4 +71,6 @@ public interface UserService {
void
setAccountLockLocal
(
String
uuid
,
boolean
locked
);
void
userEmailValidated
(
String
uuid
);
void
addVettedUserRole
(
String
uuid
);
}
src/main/java/org/genesys2/server/service/impl/UserServiceImpl.java
View file @
3a5c576f
...
...
@@ -16,12 +16,6 @@
package
org.genesys2.server.service.impl
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.genesys2.server.exception.NoUserFoundException
;
...
...
@@ -52,6 +46,8 @@ import org.springframework.security.crypto.password.PasswordEncoder;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.*
;
@Service
@Transactional
(
readOnly
=
true
)
public
class
UserServiceImpl
implements
UserService
{
...
...
@@ -349,10 +345,27 @@ public class UserServiceImpl implements UserService {
addRoleToCurrentUser
(
user
,
UserRole
.
VALIDATEDUSER
.
getName
());
LOG
.
info
(
"Ensured VALIDATEDUSER role for user "
+
user
);
}
catch
(
UserException
e
)
{
LOG
.
error
(
e
);
}
}
@Override
public
void
addVettedUserRole
(
String
uuid
){
User
user
=
userPersistence
.
findByUuid
(
uuid
);
Set
<
UserRole
>
userRoles
=
user
.
getRoles
();
userRoles
.
add
(
UserRole
.
VETTEDUSER
);
try
{
updateUser
(
user
);
addRoleToCurrentUser
(
user
,
UserRole
.
VETTEDUSER
.
getName
());
LOG
.
info
(
"Add role VETTEDUSER for user "
+
user
);
}
catch
(
UserException
e
)
{
LOG
.
error
(
e
);
}
}
private
void
addRoleToCurrentUser
(
User
user
,
String
role
)
{
Object
principal
=
SecurityContextHolder
.
getContext
().
getAuthentication
().
getPrincipal
();
...
...
src/main/java/org/genesys2/server/servlet/controller/UserProfileController.java
View file @
3a5c576f
...
...
@@ -80,6 +80,13 @@ 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:.+}"
)
@PreAuthorize
(
"isAuthenticated()"
)
public
String
someProfile
(
ModelMap
model
,
@PathVariable
(
"uuid"
)
String
uuid
)
{
...
...
src/main/webapp/WEB-INF/jsp/user/index.jsp
View file @
3a5c576f
...
...
@@ -28,6 +28,7 @@
<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>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment