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 a Next.js app (version 14), where I have implemented user authentication and authorization using NextAuth v4 (Google OAuth). In my app, I have a protected page at /credits.
When I try to visit the Credits page (without being logged in), I get redirected to the Login page at /login. On the Login page, the URL is: http:localhost:3000/login?from=%2Fcredits.
I want to save the value of the from query param in my database after successful log in. My question is: how do I make this value available inside any of the callbacks (signIn, jwt or session)? Important point: The callback function where the from query param value is made available should also have access to the user email address.
If this is not the right approach, then what other way would you suggest?
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
Uh oh!
There was an error while loading. Please reload this page.
-
I have a Next.js app (version 14), where I have implemented user authentication and authorization using NextAuth v4 (Google OAuth). In my app, I have a protected page at
/credits
.When I try to visit the Credits page (without being logged in), I get redirected to the Login page at
/login
. On the Login page, the URL is:http:localhost:3000/login?from=%2Fcredits
.Here is what the
signIn
function looks like:I want to save the value of the
from
query param in my database after successful log in. My question is: how do I make this value available inside any of the callbacks (signIn, jwt or session)? Important point: The callback function where thefrom
query param value is made available should also have access to the user email address.If this is not the right approach, then what other way would you suggest?
Beta Was this translation helpful? Give feedback.
All reactions