39 lines
838 B
TypeScript
39 lines
838 B
TypeScript
/* eslint-disable @typescript-eslint/unbound-method */
|
|
/* @see https://github.com/nextauthjs/next-auth/pull/8932 */
|
|
|
|
import Discord from "@auth/core/providers/discord";
|
|
import type { DefaultSession } from "@auth/core/types";
|
|
import { DrizzleAdapter } from "@auth/drizzle-adapter";
|
|
import NextAuth from "next-auth";
|
|
|
|
import { db, tableCreator } from "@acme/db";
|
|
|
|
export type { Session } from "next-auth";
|
|
|
|
declare module "next-auth" {
|
|
interface Session {
|
|
user: {
|
|
id: string;
|
|
} & DefaultSession["user"];
|
|
}
|
|
}
|
|
|
|
export const {
|
|
handlers: { GET, POST },
|
|
auth,
|
|
signIn,
|
|
signOut,
|
|
} = NextAuth({
|
|
adapter: DrizzleAdapter(db, tableCreator),
|
|
providers: [Discord],
|
|
callbacks: {
|
|
session: ({ session, user }) => ({
|
|
...session,
|
|
user: {
|
|
...session.user,
|
|
id: user.id,
|
|
},
|
|
}),
|
|
},
|
|
});
|