diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f68ba71..3e31a5b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,6 +12,7 @@ env: # Find a workaround for this. DATABASE_URL: "postgresql://admin:admin@localhost:5432/cooper?schema=public" + NEXTAUTH_URL: "localhost:3000" NEXTAUTH_SECRET: "sec" GOOGLE_CLIENT_ID: "cooper" GOOGLE_CLIENT_SECRET: "cooper" diff --git a/src/server/auth.ts b/src/server/auth.ts index ac7e6ad..389a9e6 100644 --- a/src/server/auth.ts +++ b/src/server/auth.ts @@ -5,7 +5,6 @@ import { type NextAuthOptions, } from "next-auth"; import GoogleProvider from "next-auth/providers/google"; -import CredentialsProvider from "next-auth/providers/credentials"; import { env } from "~/env"; import { db } from "~/server/db"; @@ -30,53 +29,6 @@ declare module "next-auth" { // // role: UserRole; // } } - -/** - * Provider to be used in a production environment. - */ -const productionProviders = [ - GoogleProvider({ - clientId: env.GOOGLE_CLIENT_ID ?? "", - clientSecret: env.GOOGLE_CLIENT_SECRET ?? "", - }), - /** - * ...add more providers here. - * - * Most other providers require a bit more work than the Discord provider. For example, the - * GitHub provider requires you to add the `refresh_token_expires_in` field to the Account - * model. Refer to the NextAuth.js docs for the provider you want to use. Example: - * - * @see https://next-auth.js.org/providers/github - */ -]; - -/** - * Provider to be used in a Vercel Preview - */ -const previewProvider = [ - CredentialsProvider({ - name: "TEST USER", - id: "cooper-test-provider", - async authorize() { - return { - id: "1", - name: "Cooper Test User", - email: "testuser@husky.neu.edu", - image: "https://i.pravatar.cc/150?u=jsmith@example.com", - }; - }, - credentials: {}, - }), -]; - -const getProvider = () => { - if (process.env.VERCEL_ENV === "preview") { - return previewProvider; - } else { - return productionProviders; - } -}; - /** * Options for NextAuth.js used to configure adapters, providers, callbacks, etc. * @@ -93,7 +45,21 @@ export const authOptions: NextAuthOptions = { }), }, adapter: PrismaAdapter(db), - providers: getProvider(), + providers: [ + GoogleProvider({ + clientId: env.GOOGLE_CLIENT_ID ?? "", + clientSecret: env.GOOGLE_CLIENT_SECRET ?? "", + }), + /** + * ...add more providers here. + * + * Most other providers require a bit more work than the Discord provider. For example, the + * GitHub provider requires you to add the `refresh_token_expires_in` field to the Account + * model. Refer to the NextAuth.js docs for the provider you want to use. Example: + * + * @see https://next-auth.js.org/providers/github + */ + ], }; /**