Auth0 Home Blog Docs

How to add roles, permissions to a user during signup?

I have an application whose end users I like to store in Auth0 “Database” connection.
I want to have end users credentials (username + password) to authenticate them with Auth0. On Successful login, I want Auth0 to return an id_token which has a user role, permissions. Also, I want to know how I can I set these roles and permissions when a user signsup?

Hi @ilyas-shah,

Thanks for joining us in the Auth0 Community!

You can setup RBAC so your roles are automatically associated with permissions.

This FAQ shows how to add a role upon signup:

You could customize the rule to automatically set roles based on different factors like IP, email domain, etc.

You could add that role to the token as a custom claim like this:

Let me know if that helps! Also let me know if you need some more insight on this.

Thanks,
Dan

thanks @dan.woda for your quick response. I will go through these topics and get back to you in case I have a question.

1 Like

Hi @dan.woda,
I have followed the above and I can add the current user to a role.

Unfortunately the roles/permissions do not make it into the access token until they re-authenticate.

Is there anyway to refresh the token from within the rule in order to add/refresh the claims with the Issuer of “https://xxxx.eu.auth0.com/”?

This article also describes the same situation here:

I got this working as detailed here:

2 Likes