export const authOptions: NextAuthOptions = {
adapter: PrismaAdapter(db),
providers: [
GitHubProvider({
profile(profile: GithubProfile) {
return {
//this will populate the user schema based on information pulled from the auth provider
name: profile.login,
email: profile.email,
role: profile.role ?? "user",
id: profile.id.toString(),
image: profile.avatar_url,
}
},
clientId: process.env.GITHUB_ID as string,
clientSecret: process.env.GITHUB_SECRET as string,
}),
],
callbacks: {
session: ({ session, user }) => ({
...session,
user: {
...session.user,
id: user.id,
name: user.name,
role: user.role,
email: user.email
},
}),
async redirect({url, baseUrl}) {
return baseUrl
}
},
};
/**
* Wrapper for `getServerSession` so that you don't need to import the `authOptions` in every file.
*
* @see https://next-auth.js.org/configuration/nextjs
*/
export const getServerAuthSession = () => getServerSession(authOptions);
export const authOptions: NextAuthOptions = {
adapter: PrismaAdapter(db),
providers: [
GitHubProvider({
profile(profile: GithubProfile) {
return {
//this will populate the user schema based on information pulled from the auth provider
name: profile.login,
email: profile.email,
role: profile.role ?? "user",
id: profile.id.toString(),
image: profile.avatar_url,
}
},
clientId: process.env.GITHUB_ID as string,
clientSecret: process.env.GITHUB_SECRET as string,
}),
],
callbacks: {
session: ({ session, user }) => ({
...session,
user: {
...session.user,
id: user.id,
name: user.name,
role: user.role,
email: user.email
},
}),
async redirect({url, baseUrl}) {
return baseUrl
}
},
};
/**
* Wrapper for `getServerSession` so that you don't need to import the `authOptions` in every file.
*
* @see https://next-auth.js.org/configuration/nextjs
*/
export const getServerAuthSession = () => getServerSession(authOptions);