Is it possible to obtain the token variable or user session inside redirect callback ? #8950
Replies: 1 comment 2 replies
-
found the answer. thx |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
My purpose is to redirect user to a different page based on user attribute (from user object or token or popupated session) calledd user type. Is it possible to achieve it inside redirect callback ? I'm not sure how to get the user data in redirect callback.
Currently the signature for redirect callbcak in next_auth api is defined like the following:
...
callbacks: {
async redirect({ url, baseUrl }) {
// Allows relative callback URLs
if (url.startsWith("/")) return
${baseUrl}${url}
// Allows callback URLs on the same origin
else if (new URL(url).origin === baseUrl) return url
return baseUrl
}
}
...
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions