How to fetch role by using dataManager.load(User.class)

Hi,

how to load role by using. i am able to get username and firstname of the user but i am unable to get role of the user.

List<User> roleAssignment = dataManager.load(User.class)
                        .condition(PropertyCondition.equal("username", "test")).list();

tried below code to get role but getting null

roleAssignment.getAuthorities().stream().findFirst().get().getAuthority()

1 Like

Hi,

The authorities collection is filled only for currently logged in user. If you want to get a collection of role assignment for some specific user then try the following service method: io.jmix.security.role.assignment.RoleAssignmentRepository#getAssignmentsByUsername

1 Like