feat: implement user authentication and authorization with NextAuth, including user schema, password hashing, and role-based access control.

This commit is contained in:
Michael committed 2026-02-22 14:11:36 +01:00
1 parent c842c2447a
commit 359d196c4d
18 files changed
+652 -32

No files matched your search

+11 -2
View File
@@ -2,11 +2,20 @@
import { db } from "@/db";
import { sessionSnapshots } from "@/db/schema";
import { eq } from "drizzle-orm";
import { and, eq } from "drizzle-orm";
import { auth } from "@/lib/auth";
export async function deleteSnapshot(id: number) {
const session = await auth();
const userId = session?.user ? Number((session.user as any).id) : null;
if (!userId) {
return { success: false, error: "Non autorisé" };
}
try {
await db.delete(sessionSnapshots).where(eq(sessionSnapshots.id, id));
await db.delete(sessionSnapshots)
.where(and(eq(sessionSnapshots.id, id), eq(sessionSnapshots.userId, userId)));
return { success: true };
} catch (err) {
console.error(err);