Recommended Hooks Pre User Registration

I am trying to create a hook for a user during pre-registration to register the user to a company. Each user is required to join a company or create a new one during registration.

This is my first time using Auth0 Hooks
Any useful resources anyone knows online would be great.

Hi @DseeHappy,

Thanks for joining the Community!

In order for the user to join a company, do you need to send the data somewhere (make an API request) or do you just need to update the user’s metadata to store their company information?

If it is simply storing the company info in the user’s metadata, here is an example script to follow: Explore Flows and Triggers

If you are wanting to send the data elsewhere, you may want to use a post-user registration hook instead which is non-blocking and designed for asynchronous tasks.

1 Like

Thanks for replying,

Preferably, I would be able to check if a user has a company set, if not to route to create | join company page.
From there I wasn’t sure if it would be best to store the company data as user metadata within auth0 or just send that straight to my neo4j DB or both.

I plan on setting user roles within a company for Owner, Manager, Employee, Contractor, Customer.
In this case would it be best to set up the data as metadata within auth0 and setup roles?
I haven’t used auth0 much yet, recently switched to it with auth0/nextjs

How would I accept input for the company, would the user input be held within the user or the context?

Hi @DseeHappy,

Sorry for the delay in responding!

Yes, I believe this is a good approach for keeping track of user roles.

You may want to look into using the Authorization Extension: Authorization Extension

This extension will generate a rule for your application which will add role data to the user’s metadata upon successful login.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.