Skip to content

Commit

Permalink
revert(auth): revert to old code
Browse files Browse the repository at this point in the history
  • Loading branch information
RishikeshNK committed Feb 3, 2024
1 parent 153b230 commit 7ff9a8c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 49 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
64 changes: 15 additions & 49 deletions src/server/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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: "[email protected]",
image: "https://i.pravatar.cc/[email protected]",
};
},
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.
*
Expand All @@ -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
*/
],
};

/**
Expand Down

0 comments on commit 7ff9a8c

Please sign in to comment.