I’m trying to get a list of all the users with the role manager
which have been invited but haven’t accepted their invitation yet (so essentially their email_verified
is still false).
For now, I’m doing this using Java:
public List<User> getInvitedManagers() throws Auth0Exception {
List<User> usersWithManagerRole = managementAPI.roles().listUsers(managerRoleId, null).execute().getItems();
// Data returned from roles().listUsers() doesn't include isEmailVerified() information so we need to fetch user's details
List<User> usersWithDetails = new ArrayList<User>();
for(User user: usersWithManagerRole) {
User userWithDetails = managementAPI.users().get(user.getId(), null).execute();
usersWithDetails.add(userWithDetails);
}
List<User> invitedManagers = usersWithDetails.stream().filter(manager -> !manager.isEmailVerified()).collect(Collectors.toList());
return invitedManagers;
}
This seems like a really bad way to query for this information. However I couldn’t find any other way. Ideally, I should be able to just write a query within the managementAPI.users().list()
function, but I also need to query for the role
of the user and I guess that’s not possible within the user query string.
Please let me know if there is a better way to do this?