Save roles and permission in my mongodb

Hello everyone,

I’m pretty new with auth0 and all this world so my question could be easy to anwer…
Im trying to do this two things and I dont find the way to do so.

  1. When I register a new user I would also like to save roles and permission in my ddbb (I’m using mongodatabase). Now name,email,password and other are saved but roles and permissions are not.

  2. I would like to know what is the format of roles and permission so I could implement this in my local enviroment. I mean, when I register a new user “imitate” this to develop and test in my local enviroment without risking the realdatabase

I hope you could help me! Thanks!

Hi @agustin.soler,

Welcome to the Auth0 Community!

First, could you please clarify how you have managed to save the name, email, and password in your MongoDB?

Now, to save roles and permissions in your MongoDB you could consider using a Post-User Registration Action to accomplish this. This way you can programmatically save these roles and permissions to your MongoDB for every new user that signs up.

You could refer to the Management API v2 Get a user’s role endpoint and Get a user’s permissions endpoint to learn more about the structure of the response. This should help you determine how to build your schema.

Hoped this helps!

Thank you.

Hi @rueben.tiow
Thank you so much !

I’ve connected my mongo database to auth0 and I developed their respective methods (loguin user, create,etc)
But when I check my database I am not able to find roles and permissions.
This is what I get:

I’ve been reading about the action but it is not very clear (at least for me)

You could refer to the Management API v2 Get a user’s role endpoint and Get a user’s permissions endpoint to learn more about the structure of the response. This should help you determine how to build your schema.

So is it possible to post from my backend a new user ?