-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.config.ts
40 lines (35 loc) · 1.1 KB
/
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
31
32
33
34
35
36
37
38
39
40
import { prisma } from "@/lib/prisma";
import CredentialsProvider from "next-auth/providers/credentials";
import GithubProvider from "next-auth/providers/github";
import type { NextAuthConfig } from "next-auth";
export default {
providers: [
GithubProvider,
CredentialsProvider({
name: "Credentials",
credentials: {
email: { label: "Email", type: "email" },
password: { label: "Password", type: "password" },
},
async authorize(credentials) {
if (!credentials?.email || !credentials?.password) return null;
const user = await prisma.user.findUnique({
where: {
email: credentials.email as string,
},
});
if (!user) return null;
if (user && user.hashedPassword === credentials.password) {
return {
id: user.id,
name: user.name,
email: user.email,
roleUser: user.roleUser,
tokens: user.tokens,
};
}
return null;
},
}),
],
} satisfies NextAuthConfig;