Auth0 Home Blog Docs

Automatically add a default role to a newly created User (on sign up)

user-creation
roles
authorization-extens

#1

Is there a way to Automatically add a default role to a newly created User (on sign up)? I am using the Authorization extension for groups, roles, permission management.

As a work around I temporarily assign the default role as a part of sigh in process if the user does not belong to any role.


#2

To my knowledge there’s nothing at the extension level in terms of assigning a default role to users which means that the current approach you’re taking is valid. The extension does seem to cater for automatic group mapping based on user connections, this is not exactly what you mentioned, but wanted to bring your attention to this in case it can be useful.


#3

Hey, I have a similar use case and it sounds like what you did is the correct solution. One question, did you add the user to the Authorization Role or just to the id and access token? I want to add to the Authorization Role, do you have a sample code snippet of how this is done?

So far I have found examples of just adding the role to either the id or access token being returned.


#4