Session does not persist after a successfulPayment stripe redirect
Unanswered
Eurasian Wigeon posted this in #help-forum
Eurasian WigeonOP
I'm using auth v5, the credentials provider session persists after the stripre redirect, but the Oauth sessions are not persisted after a stripe redirect, any suggestion or solutions for this issue would be much appreciated.
auth,s
import NextAuth, {Session} from "next-auth";
import Google from "next-auth/providers/google";
import Github from "next-auth/providers/github";
import credentials from "next-auth/providers/credentials";
import prisma from "./db";
import bycrptjs from "bcryptjs";
import {Prisma} from "@prisma/client";
const authConfig = {
providers: [
//google, github, credentialsProvider
],
callbacks: {
authorized({auth, request}: {auth: any; request: any}) {
return !!auth?.user;
},
async signIn({user}: {user: any}) {
try {
const existingGuest = await prisma.user.findUnique({
where: {
email: user.email,
},
});
let authUser: Prisma.UserCreateInput;
if (!existingGuest) {
authUser = {
email: user.email as string,
name: user.name as string,
image: user.image as string,
};
await prisma.user.create({
data: authUser,
});
}
return true;
} catch (error: any) {
console.error("Error in signIn callback:", error);
return false;
}
},
},
pages: {
signIn: "/login",
},
};
export const {
auth,
handlers: {GET, POST},
signIn,
signOut,
} = NextAuth({
session: {strategy: "jwt"},
...authConfig,
});
auth,s
import NextAuth, {Session} from "next-auth";
import Google from "next-auth/providers/google";
import Github from "next-auth/providers/github";
import credentials from "next-auth/providers/credentials";
import prisma from "./db";
import bycrptjs from "bcryptjs";
import {Prisma} from "@prisma/client";
const authConfig = {
providers: [
//google, github, credentialsProvider
],
callbacks: {
authorized({auth, request}: {auth: any; request: any}) {
return !!auth?.user;
},
async signIn({user}: {user: any}) {
try {
const existingGuest = await prisma.user.findUnique({
where: {
email: user.email,
},
});
let authUser: Prisma.UserCreateInput;
if (!existingGuest) {
authUser = {
email: user.email as string,
name: user.name as string,
image: user.image as string,
};
await prisma.user.create({
data: authUser,
});
}
return true;
} catch (error: any) {
console.error("Error in signIn callback:", error);
return false;
}
},
},
pages: {
signIn: "/login",
},
};
export const {
auth,
handlers: {GET, POST},
signIn,
signOut,
} = NextAuth({
session: {strategy: "jwt"},
...authConfig,
});