Added user tab and oauth2, streamlined readme
This commit is contained in:
+20
-1
@@ -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(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user