You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have what seems to be a conceptual doubt about where and how to implement user role logic in a next-auth app and which approach is the most conventional.
Namely when using something like this
providers: [
Auth0Provider({
clientId: env.AUTH0_CLIENT_ID,
clientSecret: env.AUTH0_CLIENT_SECRET,
issuer: env.AUTH0_ISSUER,
profile(profile) {
return {
id: profile.sub,
name: profile.name,
email: profile.email,
image: profile.picture,
role: //HERE I CAN SET
} as User;
},
}),
],
This correctly sets up the role when hardcoded, the Prisma adapter is working too and I can get it all the way to the frontend with the session callback
What I don't understand is where to get this logic from, how can I send it to next-auth.
The only thing I can come up with is something like setting a cookie with the role, let's say I have two buttons one for customer signup and another for partner signup, before redirecting to /api/auth/signin I could set a cookie, but this is kind of ugly to do it next-js app router from the client side, and I seem to be missing something obvious here.
What is the most common/recommended approach for this? How can I pass the logic down to the options?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have what seems to be a conceptual doubt about where and how to implement user role logic in a next-auth app and which approach is the most conventional.
Namely when using something like this
This correctly sets up the role when hardcoded, the Prisma adapter is working too and I can get it all the way to the frontend with the session callback
What I don't understand is where to get this logic from, how can I send it to next-auth.
The only thing I can come up with is something like setting a cookie with the role, let's say I have two buttons one for customer signup and another for partner signup, before redirecting to
/api/auth/signin
I could set a cookie, but this is kind of ugly to do it next-js app router from the client side, and I seem to be missing something obvious here.What is the most common/recommended approach for this? How can I pass the logic down to the options?
Beta Was this translation helpful? Give feedback.
All reactions