diff --git a/auth.ts b/auth.ts index 0b714d6..5c7c1dd 100644 --- a/auth.ts +++ b/auth.ts @@ -1,25 +1,18 @@ -import NextAuth, { type DefaultSession } from 'next-auth' +import NextAuth from 'next-auth' import GitHub from 'next-auth/providers/github' -declare module 'next-auth' { - interface Session { - user: { - /** The user's id. */ - id: string - } & DefaultSession['user'] - } -} - export const { handlers: { GET, POST }, auth, CSRF_experimental + // @ts-ignore } = NextAuth({ // @ts-ignore providers: [GitHub], callbacks: { + // @ts-ignore jwt: async ({ token, profile }) => { - if (profile) { + if (profile?.id) { token.id = profile.id token.image = profile.picture } diff --git a/next-auth.d.ts b/next-auth.d.ts new file mode 100644 index 0000000..918e14d --- /dev/null +++ b/next-auth.d.ts @@ -0,0 +1,13 @@ +import NextAuth, { DefaultSession } from 'next-auth' + +declare module 'next-auth' { + /** + * Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context + */ + interface Session { + user: { + /** The user's postal address. */ + id: string + } & DefaultSession['user'] + } +} diff --git a/tsconfig.json b/tsconfig.json index 9be1cf1..9f91b9b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,6 +26,7 @@ }, "include": [ "next-env.d.ts", + "next-auth.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"