-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.config.ts
More file actions
58 lines (57 loc) · 1.6 KB
/
auth.config.ts
File metadata and controls
58 lines (57 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// import { AuthOptions } from "next-auth";
// import GoogleProvider from "next-auth/providers/google";
// import { checkAllowedEmail } from "./app/api/auth/check-email/route";
//
// export const authOptions: AuthOptions = {
// providers: [
// GoogleProvider({
// clientId: process.env.GOOGLE_CLIENT_ID!,
// clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
// }),
// ],
// callbacks: {
// async signIn({ user }) {
// const isAllowedEmail = await checkAllowedEmail(user.email as string);
//
// if (isAllowedEmail) {
// return true;
// } else {
// return false;
// }
// },
// },
// pages: {
// error: '/auth/error',
// },
// debug: process.env.NODE_ENV === 'development',
// };
import GoogleProvider from "next-auth/providers/google";
import { Session } from "next-auth";
import { checkAllowedEmail } from "@/app/utils/check-email";
export const authOptions = {
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
}),
],
callbacks: {
async signIn({ user }: { user: { email?: string | null } }) {
try {
const isAllowedEmail = await checkAllowedEmail(user.email as string);
return isAllowedEmail;
} catch (error) {
console.error("Error in signIn callback:", error);
return false;
}
},
async session({ session }: { session: Session }) {
return session;
},
},
pages: {
error: '/auth/error',
signIn: '/auth/signin',
},
debug: process.env.NODE_ENV === 'development',
};