diff --git a/components/InstallApp.tsx b/components/InstallApp.tsx index f191f006..50071da6 100644 --- a/components/InstallApp.tsx +++ b/components/InstallApp.tsx @@ -8,7 +8,7 @@ const InstallApp = (props: Props) => { const [isOpen, setIsOpen] = useState(true); return isOpen && !isPWA() ? ( -
+
0) { + await prisma.user.update({ + where: { + id: userExists.id, + }, + data: { + emailVerified: new Date(), + }, + }); + } + + if (userExists && !userExists.username) { const autoGeneratedUsername = "user" + Math.round(Math.random() * 1000000000); @@ -1217,6 +1264,22 @@ export default async function auth(req: NextApiRequest, res: NextApiResponse) { }, }); } + } else if (trigger === "signIn") { + const user = await prisma.user.findUnique({ + where: { + id: token.id, + }, + }); + + if (user && !user.username) { + const autoGeneratedUsername = + "user" + Math.round(Math.random() * 1000000000); + + await prisma.user.update({ + where: { id: user.id }, + data: { username: autoGeneratedUsername }, + }); + } } return token; @@ -1224,6 +1287,8 @@ export default async function auth(req: NextApiRequest, res: NextApiResponse) { async session({ session, token }) { session.user.id = token.id; + console.log("session", session); + if (STRIPE_SECRET_KEY) { const user = await prisma.user.findUnique({ where: { @@ -1235,6 +1300,7 @@ export default async function auth(req: NextApiRequest, res: NextApiResponse) { }); if (user) { + // const subscribedUser = await verifySubscription(user); } }