-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.ts
39 lines (32 loc) · 1.16 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
import NextAuth from "next-auth";
import Credentials from "next-auth/providers/credentials";
import { authConfig } from "./auth.config";
export const { handlers, signIn, signOut, auth } = NextAuth({
...authConfig,
providers: [
Credentials({
// You can specify which fields should be submitted, by adding keys to the `credentials` object.
// e.g. domain, username, password, 2FA token, etc.
credentials: {
email: {},
password: {},
},
authorize: async (_credentials) => {
let user = null;
// logic to salt and hash password
//const pwHash = saltAndHashPassword(credentials.password);
// logic to verify if user exists
//user = await getUserFromDb(credentials.email, pwHash);
user = { id: "test", email: "[email protected]" };
if (!user) {
// No user found, so this is their first attempt to login
// meaning this is also the place you could do registration
throw new Error("User not found.");
}
// return user object with the their profile data
return user;
},
}),
],
pages: { signIn: "/sign-in" },
});