I have multiple cases to handle to redirect user according multiple fields and custom claims in the user token (it’s little bit complex if/else blocks)
taking the first and the simpler example to redirect user to /email-verification
if the user.email_verified
is false
const afterCallback = async (req: any, session: any, state: any) => {
// const router = useRouter()
const res = new NextResponse()
if (session.user) {
// check email
if (!session.user.email_verified) {
// router.push("/auth/email-verification")
// redirect("/auth/email-verification", RedirectType.replace)
return Response.redirect(
"http://localhost:3000/auth/email-verification",
308 // just for testing
)
} else {
// MULTI LEVELS IF-ELSE BLOCKS WITH REDIRECTION
}
return session
export const GET = handleAuth({
login: handleLogin({
returnTo: "/",
}),
callback: async (req: any, res: any) => {
const callback = await handleCallback(req, res, { afterCallback })
console.log("callback", callback)
return callback;
},
})
I always get redirected to http://localhost:3000
with no user data, in addition logging the callback const status found that it’s 302
and not 308
i’m using