How to Redirect Users to a Wizard Page if They Lack a Required Attribute (Next.js & Auth0)
Unanswered
Siamese posted this in #help-forum
SiameseOP
I'm building a Next.js application where users log in via Auth0. After authentication, I need to check whether the user has a specific attribute by calling an external API. If the attribute is missing, the user should be redirected to a wizard page to complete the required information.
Here's the flow I want to implement:
1. The user logs in via Auth0.
2. After successful authentication, the system calls an API to fetch user attributes.
3. If the user lacks the required attribute, they should be redirected to a wizard page. Otherwise, they proceed as usual.
I'm looking for guidance on the best way to implement this in a Next.js app. Specifically:
- Where should the API call be made—during the authentication callback or inside a middleware?
- How can I efficiently redirect users without the required attribute while keeping authentication secure?
- Would using Next.js middleware (
Any suggestions, best practices, or example implementations would be greatly appreciated!
Here's the flow I want to implement:
1. The user logs in via Auth0.
2. After successful authentication, the system calls an API to fetch user attributes.
3. If the user lacks the required attribute, they should be redirected to a wizard page. Otherwise, they proceed as usual.
I'm looking for guidance on the best way to implement this in a Next.js app. Specifically:
- Where should the API call be made—during the authentication callback or inside a middleware?
- How can I efficiently redirect users without the required attribute while keeping authentication secure?
- Would using Next.js middleware (
middleware.ts
) be a good approach, or is there a better alternative? Any suggestions, best practices, or example implementations would be greatly appreciated!