-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroute.ts
More file actions
38 lines (35 loc) · 957 Bytes
/
Copy pathroute.ts
File metadata and controls
38 lines (35 loc) · 957 Bytes
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
import NextAuth from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials";
type UserToken = { id: string; name: string; email: string };
const handler = NextAuth({
providers: [
CredentialsProvider({
name: "Credentials",
credentials: {
username: { label: "Username", type: "text", placeholder: "admin" },
password: {
label: "Password",
type: "password",
placeholder: "1234",
},
},
async authorize(credentials, req) {
return { id: "1", name: "Admin", email: "admin@example.com" };
},
}),
],
secret: process.env.NEXTAUTH_SECRET,
callbacks: {
async jwt({ token, user }) {
if (user) {
token.user = user;
}
return token;
},
async session({ session, token }) {
session.user = token.user as UserToken;
return session;
},
},
});
export { handler as GET, handler as POST };