borders/pages/api/auth/[...nextauth].js

22 lines
583 B
JavaScript
Raw Normal View History

2022-04-10 16:34:29 +00:00
import NextAuth from "next-auth";
import DiscordProvider from "next-auth/providers/discord";
2022-04-10 18:26:47 +00:00
import { PrismaAdapter } from "@next-auth/prisma-adapter";
import prisma from "../../../lib/prisma";
2022-04-10 16:34:29 +00:00
export default NextAuth({
2022-04-10 18:26:47 +00:00
adapter: PrismaAdapter(prisma),
2022-04-10 16:34:29 +00:00
providers: [
DiscordProvider({
clientId: process.env.DISCORD_CLIENT_ID,
clientSecret: process.env.DISCORD_CLIENT_SECRET,
}),
],
2022-04-10 18:26:47 +00:00
callbacks: {
async session({ session, token, user }) {
session.user.id = user.id;
2022-04-11 17:33:16 +00:00
// console.log(JSON.stringify(user));
2022-04-10 18:26:47 +00:00
return session;
},
},
2022-04-10 16:34:29 +00:00
});