-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.config.ts
30 lines (27 loc) · 910 Bytes
/
auth.config.ts
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
// import bcrypt from "bcryptjs";
import type { NextAuthConfig } from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials";
import GoogleProvider from "next-auth/providers/google";
import { db } from "./lib/db";
export default {
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
}),
CredentialsProvider({
async authorize(credentials) {
if (!credentials || !credentials.email || !credentials.password)
return null;
const dbUser = await db.admin_user.findFirst({
where: { email: credentials.email },
});
if (dbUser && dbUser.password === credentials.password) {
const { password, id } = dbUser;
return dbUser;
}
return null;
},
}),
],
} satisfies NextAuthConfig;