Spaces:
Running
Running
Download auth.ts from Jacksuyu/demandsolution-codex: direct link, hf CLI and curl.
- Browser
- Download file 782 Bytes
-
https://huggingface.co/spaces/Jacksuyu/demandsolution-codex/resolve/main/auth.ts
- Command line
-
hf download hf://spaces/Jacksuyu/demandsolution-codex/auth.ts
-
curl -L -o auth.ts https://huggingface.co/spaces/Jacksuyu/demandsolution-codex/resolve/main/auth.ts
782 Bytes
| import NextAuth from "next-auth"; | |
| import Google from "next-auth/providers/google"; | |
| import { PrismaAdapter } from "@auth/prisma-adapter"; | |
| import { prisma } from "@/lib/prisma"; | |
| const providers = | |
| process.env.AUTH_GOOGLE_ID && process.env.AUTH_GOOGLE_SECRET | |
| ? [ | |
| Google({ | |
| clientId: process.env.AUTH_GOOGLE_ID, | |
| clientSecret: process.env.AUTH_GOOGLE_SECRET, | |
| }), | |
| ] | |
| : []; | |
| export const { handlers, auth, signIn, signOut } = NextAuth({ | |
| adapter: PrismaAdapter(prisma), | |
| providers, | |
| session: { strategy: "database" }, | |
| trustHost: true, | |
| pages: { | |
| signIn: "/login", | |
| }, | |
| callbacks: { | |
| async session({ session, user }) { | |
| if (session.user) { | |
| session.user.id = user.id; | |
| } | |
| return session; | |
| }, | |
| }, | |
| }); | |