Added user tab and oauth2, streamlined readme

This commit is contained in:
fuomag9
2025-12-28 15:14:56 +01:00
parent f8a673cc03
commit be21f46ad5
28 changed files with 3213 additions and 245 deletions
+20 -1
View File
@@ -1,4 +1,4 @@
import db, { toIso } from "../db";
import db, { toIso, nowIso } from "../db";
import { auditEvents } from "../db/schema";
import { desc } from "drizzle-orm";
@@ -29,3 +29,22 @@ export async function listAuditEvents(limit = 100): Promise<AuditEvent[]> {
created_at: toIso(event.createdAt)!
}));
}
export async function createAuditEvent(data: {
userId: number | null;
action: string;
entityType: string;
entityId?: number | null;
summary?: string | null;
data?: string | null;
}): Promise<void> {
await db.insert(auditEvents).values({
userId: data.userId,
action: data.action,
entityType: data.entityType,
entityId: data.entityId ?? null,
summary: data.summary ?? null,
data: data.data ?? null,
createdAt: nowIso(),
});
}
+1 -1
View File
@@ -71,7 +71,7 @@ export async function createUser(data: {
passwordHash?: string | null;
}): Promise<User> {
const now = nowIso();
const role = data.role ?? "user";
const role = data.role ?? "admin"; // All users are admin by default
const email = data.email.trim().toLowerCase();
const [user] = await db