I have a question about user roles. When I create roles and assign a role to a user, I expect to retrieve a list of users using ‘event.authorization.roles’ in PostLogin. However, the array is always empty (), even though other details like username and metadata are returned correctly.
Welcome to the Auth0 Community!
If you have assigned roles to a user via the Auth0 Dashboard, they should be present in the event.authorization.roles
parameter inside the PostLogin Action
.
I have just tested this on my end with an user who has assigned roles using the Real-Time Webtask Logs
extension available within the Auth0 and I was able to retrieve the user roles as seen below:
USER ROLES
ACTION CODE
exports.onExecutePostLogin = async (event, api) => {
console.log(event.authorization.roles)
}
LOG OUTPUT
If you have any other questions, let me know!
Kind Regards,
Nik