-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.ts
More file actions
23 lines (22 loc) · 791 Bytes
/
auth.ts
File metadata and controls
23 lines (22 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import NextAuth from "next-auth";
import Google from "next-auth/providers/google";
import NeonAdapter from "@auth/neon-adapter";
import { Pool } from "@neondatabase/serverless";
export const { handlers, auth, signIn, signOut } = NextAuth(() => {
// Create a `Pool` inside the request handler.
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
return {
adapter: NeonAdapter(pool),
providers: [Google],
callbacks: {
async session({ session, user }) {
// When using database adapter, user contains the database user object
// Add is_verified to session from database user
if (session?.user && user) {
session.user.is_verified = user.is_verified ?? false;
}
return session;
},
},
};
});