what am i doing wrong cant get user.id
import DiscordProvider from "next-auth/providers/discord";
import {NextAuthOptions} from "next-auth"
declare module "next-auth" {
interface Session {
user: User;
}
}
interface User {
id: string;
name: string;
image: string;
email: string;
}
// code here
export const authOptions: NextAuthOptions = { providers: [
DiscordProvider({
clientId: process.env.CLIENT_ID as string,
clientSecret: process.env.CLIENT_SECRET as string,
authorization: {
params: {
scope: "identify guilds"
}
}
}),
],
callbacks: {
async jwt({token, user}) {
if (user) {
token.sub = user.id;
}
return token;
},
async session({session, user}) {
if (user) {
session.user.id = user.id;
}
return session;
}
},
}