Initial commit: EduBox V2 platform

This commit is contained in:
root
2026-06-06 19:55:41 +00:00
commit 0a73a70820
69 changed files with 5634 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
import CredentialsProvider from "next-auth/providers/credentials";
import { prisma } from "./prisma";
import { verifyPassword } from "./auth";
export const authOptions = {
providers: [
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 },
});
if (!user) return null;
const valid = await verifyPassword(credentials.password, user.password);
if (!valid) return null;
return { id: user.id, email: user.email, role: user.role, establishmentId: user.establishmentId ?? undefined };
},
}),
],
callbacks: {
async jwt({ token, user }: any) {
if (user) {
token.role = user.role;
token.establishmentId = user.establishmentId;
}
return token;
},
async session({ session, token }: any) {
session.user.role = token.role;
session.user.establishmentId = token.establishmentId;
return session;
},
},
pages: {
signIn: "/login",
},
session: {
strategy: "jwt" as const,
},
};