You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by bh...@apache.org on 2019/09/05 14:15:09 UTC
[incubator-dlab] branch develop updated: DLAB-1060 fixed bug
connected with roles
This is an automated email from the ASF dual-hosted git repository.
bhliva pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/develop by this push:
new f56d671 DLAB-1060 fixed bug connected with roles
f56d671 is described below
commit f56d67187f32c29e2b883da867bf707820c47e37
Author: bhliva <bo...@epam.com>
AuthorDate: Thu Sep 5 17:14:11 2019 +0300
DLAB-1060 fixed bug connected with roles
---
.../java/com/epam/dlab/backendapi/roles/UserRoles.java | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/roles/UserRoles.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/roles/UserRoles.java
index 0767c64..bbcf6da 100644
--- a/services/self-service/src/main/java/com/epam/dlab/backendapi/roles/UserRoles.java
+++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/roles/UserRoles.java
@@ -70,16 +70,16 @@ public class UserRoles {
LOGGER.trace("Loading roles from database...");
if (userRoles == null) {
userRoles = new UserRoles();
- userRoles.load(dao, defaultAccess);
- LOGGER.trace("New roles are : {}", getRoles());
}
+ userRoles.load(dao, defaultAccess);
+ LOGGER.trace("New roles are : {}", getRoles());
}
/**
* Return the list of roles for all users.
*/
public static List<UserRole> getRoles() {
- return (userRoles == null ? null : userRoles.roles);
+ return (userRoles == null ? null : userRoles.roles());
}
/**
@@ -97,12 +97,8 @@ public class UserRoles {
public static boolean isAdmin(UserInfo userInfo) {
final List<UserRole> roles = UserRoles.getRoles();
- if (roles == null || roles.isEmpty()) {
- System.out.println("=============EMPTY==========");
- }
- final boolean b = roles == null || roles.stream().anyMatch(r -> ADMIN_ROLE_NAME.equals(r.getId()) &&
+ return roles == null || roles.stream().anyMatch(r -> ADMIN_ROLE_NAME.equals(r.getId()) &&
(userRoles.hasAccessByGroup(userInfo, r, userInfo.getRoles()) || userRoles.hasAccessByUserName(userInfo, r)));
- return b;
}
/**
@@ -149,6 +145,10 @@ public class UserRoles {
}
}
+ private synchronized List<UserRole> roles() {
+ return roles;
+ }
+
/**
* Append new role to the list if role not exists in list an return it, otherwise return
* existence role.
@@ -293,4 +293,6 @@ public class UserRoles {
.addValue(roles)
.toString();
}
+
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org