mc-dashboard/lib/auth.ts

31 lines
756 B
TypeScript
Raw Normal View History

import NextAuth from "next-auth";
import Credentials from "next-auth/providers/credentials";
export const { handlers, signIn, signOut, auth } = NextAuth({
providers: [
Credentials({
name: "Admin Login",
credentials: {
username: { label: "Username", type: "text" },
password: { label: "Password", type: "password" },
},
async authorize(credentials) {
if (
credentials?.username === process.env.ADMIN_USERNAME &&
credentials?.password === process.env.ADMIN_PASSWORD
) {
return { id: "1", name: "Admin" };
}
return null;
},
}),
],
pages: {
signIn: "/login",
},
session: {
strategy: "jwt",
maxAge: 24 * 60 * 60,
},
});