mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
cannot remove the admin role from he admin user
This commit is contained in:
@@ -67,6 +67,12 @@ public class AdminUsersREST extends AbstractREST {
|
||||
if (userModel.isAdmin() && !roles.contains(Role.ADMIN)) {
|
||||
userRoleService.save(new UserRole(user, Role.ADMIN));
|
||||
} else if (!userModel.isAdmin() && roles.contains(Role.ADMIN)) {
|
||||
if (StartupBean.ADMIN_NAME.equals(user.getName())) {
|
||||
return Response
|
||||
.status(Status.FORBIDDEN)
|
||||
.entity("You cannot remove the admin role from the admin user.")
|
||||
.build();
|
||||
}
|
||||
for (UserRole userRole : userRoleService.findAll(user)) {
|
||||
if (userRole.getRole() == Role.ADMIN) {
|
||||
userRoleService.delete(userRole);
|
||||
|
||||
Reference in New Issue
Block a user