-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.ts
46 lines (31 loc) · 1.24 KB
/
auth.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
41
42
43
44
45
46
import NextAuth from 'next-auth';
import Credentials from 'next-auth/providers/credentials';
import { authConfig } from './auth.config';
import { z } from 'zod';
export const { auth, signIn, signOut } = NextAuth({
...authConfig,
providers: [
Credentials({
async authorize(credentials) {
const parsedCredentials = z
.object({ email: z.string(), password: z.string().min(6) })
.safeParse(credentials);
if (parsedCredentials.success) {
const { email, password } = parsedCredentials.data;
console.log("email", email)
console.log("password", password)
console.log(email, password)
const isValidEmail = email === process.env.PREVIEW_USERNAME;
const passwordsMatch = password === process.env.PREVIEW_PASSWORD;
console.log(passwordsMatch, isValidEmail)
console.log(process.env.PREVIEW_USERNAME, process.env.PREVIEW_PASSWORD)
console.log("preview password" , process.env.PREVIEW_PASSWORD)
console.log("password entered" , password)
if (passwordsMatch && isValidEmail) return { email, id: "1" };
}
console.log('Invalid credentials');
return null;
},
}),
],
});