Skip to content

Commit

Permalink
trying to fix discord auth
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbovv committed Jan 9, 2025
1 parent 039a3a4 commit 9debf93
Showing 1 changed file with 22 additions and 32 deletions.
54 changes: 22 additions & 32 deletions src/server/auth/config.ts
Original file line number Diff line number Diff line change
@@ -1,58 +1,48 @@
import { PrismaAdapter } from "@auth/prisma-adapter";
import { type DefaultSession, type NextAuthConfig } from "next-auth";
import DiscordProvider from "next-auth/providers/discord";
import Google from "next-auth/providers/google"
import GoogleProvider from "next-auth/providers/google";

import { db } from "~/server/db";

/**
* Module augmentation for `next-auth` types. Allows us to add custom properties to the `session`
* object and keep type safety.
*
* @see https://next-auth.js.org/getting-started/typescript#module-augmentation
*/
declare module "next-auth" {
interface Session extends DefaultSession {
user: {
id: string;
// ...other properties
// role: UserRole;
} & DefaultSession["user"];
}

// interface User {
// // ...other properties
// // role: UserRole;
// }
}

/**
* Options for NextAuth.js used to configure adapters, providers, callbacks, etc.
*
* @see https://next-auth.js.org/configuration/options
*/
export const authConfig = {
export const authConfig: NextAuthConfig = {
providers: [
DiscordProvider,
Google
/**
* ...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
*/
// Discord OAuth2 Provider
DiscordProvider({
clientId: process.env.DISCORD_CLIENT_ID as string,
clientSecret: process.env.DISCORD_CLIENT_SECRET as string,
}),
// Google OAuth2 Provider
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
}),
],
adapter: PrismaAdapter(db),
callbacks: {
session: ({ session, user }) => ({
...session,
user: {
...session.user,
id: user.id,
},
}),
async session({ session, user }) {
return {
...session,
user: {
...session.user,
id: user.id,
},
};
},
},
} satisfies NextAuthConfig;
};

0 comments on commit 9debf93

Please sign in to comment.