Adding Roles based on signup Link

Hey everyone, I have to excuse myself before saying anything since I am not technical and being chat gpt my only technical help I could say stupid things or have a stupid problem!

I have a MERN app and I had implemented an action to add a role to the user post first login to every user that signed in. Now though I need to differentiate between two roles, I would like to have a way for which if someone is leaded to the signup page through one link he is given “Role1” after signup and if he comes from another link he is given “Role2”. Is this possible?

I know the question is probably very vague but this is as far as my technical explanation skills go, thank you in advance to anyone who can help!

Hi @nocivo,

Thanks for reaching out Auth0 Community!

While exploring your interesting use case, I conducted some research. What I discovered is that you can potentially use query parameters in your URL and capture them in Auth0 actions. However, I couldn’t find relevant documentation for this approach.

Alternatively, I experimented with another method. Consider treating your two different URLs as distinct applications in Auth0, each with its unique client ID. By utilizing event.client.client_id, you can dynamically fetch the client ID of the application from which the user originated. Subsequently, through an if condition based on the client ID, you can employ api.user.setAppMetadata() to define the user’s role. I successfully added roles to app metadata based on users arriving from two different applications (in your case, two different applications in Auth0 represent your URLs). While there might be a simpler solution, I’ll keep you informed if I come across one. Please reply in thread if you find any easier solution that will help others in community! Thanks!


Hi, thank you so much for the response!

Unfortunately I did understand what you are saying but really vaguely since I am really not technical and I don’t even know how I got up to this point (probably thanks to chatgpt :slight_smile: ). Anyway, I tackled the problem in this other way: I created a page that reads the url the user is in, I add the user role I want him to have in that url when I give him the link to sign up. So for example a recruiter will have …url/recruiter. In that url page, the user role is saved in session storage (I have no idea if this is a good way to approach this) and the user is sent to sign up on auth0. After sign up I check if session storage has a role inside, and if it does I use the management API to assign that role to the user (if he doesn’t already have a role). Apart from all the problems I have due to my very confusional redirect page that I have no idea how it works, this mechanism seems to be working at the moment, although I did recently decide to pivot into a product that doesn’t ask one of the two user types to sign up so I did all of this for nothing apparently :). Glad I learnt something new though!
Thank you again for your response!

P.S. I have a question for you developers. Is there a place or a person I can hire for not a bunch of money, that can just look at my platform and tell me if it’s structured and working correctly. I have this big problem that the platform works but I have no idea if I made a security mess or a structure mess, I really would love some professional view on this.

Hi @nocivo,

Thank you for providing insights into the design of your solution.

Based on my understanding, Auth0 extends support for overcoming challenges during solution development. However, it’s essential to note that such assistance is typically available within specific plans offered by Auth0. For instance, access to support may require being on the enterprise plan, with the option to include professional services as an add-on. It’s important to note that these services are part of a paid subscription. I apologize, and I don’t believe that Auth0 provides services that guide you in the manner you are inquiring about.