- Real email/password login backed by SQLite (better-sqlite3) - HttpOnly cookie sessions with 8h sliding TTL - Admin role: invite users via Mailgun magic-link, manage roles/status - Per-user One2Edit username mapping for job filtering - Self-service forgot-password / reset-password via email - Admin console (admin.html) with user table, invite modal, row actions - New pages: change-password, forgot-password, reset-password, accept-invite - Gated /api proxy: requires valid session, anti-hijack sessionId check - Bootstrap initial admins from INITIAL_ADMINS env var on first boot - Remove Oliver login button, SSO buttons, and legacy api.js/login.js - deploy.sh: add build-essential (for native module), npm install, data dir Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
23 lines
702 B
JavaScript
23 lines
702 B
JavaScript
const { db } = require('./db');
|
|
|
|
const stmt = db.prepare(`
|
|
INSERT INTO audit_log (actor_user_id, action, target_user_id, metadata, ip, created_at)
|
|
VALUES (@actorId, @action, @targetId, @metadata, @ip, @createdAt)
|
|
`);
|
|
|
|
function log(actorId, action, targetId = null, metadata = null, ip = null) {
|
|
try {
|
|
stmt.run({
|
|
actorId: actorId ?? null,
|
|
action,
|
|
targetId: targetId ?? null,
|
|
metadata: metadata ? JSON.stringify(metadata) : null,
|
|
ip: ip ?? null,
|
|
createdAt: Date.now(),
|
|
});
|
|
} catch (err) {
|
|
console.error('[audit] log error:', err.message);
|
|
}
|
|
}
|
|
|
|
module.exports = { log };
|