Skip to content

Commit

Permalink
Provide roles types of current user - fix NPE #78
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimbasko committed Nov 14, 2019
1 parent 605431b commit 5085927
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,21 @@ protected String getPermissionValueStr(PermissionType permissionType, int value)
}

public RolesInfo getRolesInfo() {
RolesInfo rolesInfo = new RolesInfo();
rolesInfo.permissions = getPermissionInfos();

RolesInfo rolesInfo = new RolesInfo();
rolesInfo.roles = new ArrayList<>();
User user = userSessionSource.getUserSession().getCurrentOrSubstitutedUser();

if (user == null || user.getUserRoles() == null) return rolesInfo;

rolesInfo.permissions = getPermissionInfos();

user.getUserRoles().forEach(userRole -> {
RoleInfo roleInfo = new RoleInfo();
roleInfo.roleType = userRole.getRole().getType().name();
roleInfo.roleType = userRole == null || userRole.getRole() == null || userRole.getRole().getType() == null
? ""
: userRole.getRole().getType().name();

rolesInfo.roles.add(roleInfo);
});

Expand Down

0 comments on commit 5085927

Please sign in to comment.