Audit activité utilisateurs

This commit is contained in:
2026-06-15 22:28:15 +02:00
parent f54d352b7f
commit a5b4f3e721
10 changed files with 528 additions and 21 deletions
+3
View File
@@ -18,6 +18,7 @@ import { z } from 'zod';
import db from '../db/index.js';
import { HttpError } from '../middleware/errorHandler.js';
import { sendMail, buildEmailHtml, getSmtpConfig } from '../utils/mailer.js';
import { audit } from '../utils/audit.js';
const router = Router();
@@ -103,6 +104,7 @@ router.post('/', async (req, res, next) => {
}),
});
audit(req, { action: 'invitation_sent', category: 'invitation', actorId: req.user.id, details: { email, role, expiresAt } });
res.json({ ok: true, email, expiresAt });
} catch (e) { next(e); }
});
@@ -179,6 +181,7 @@ router.post('/:token/register', async (req, res, next) => {
// Marquer l'invitation comme utilisée
db.prepare("UPDATE invitations SET used_at = datetime('now') WHERE id = ?").run(inv.id);
audit(req, { action: 'invitation_accepted', category: 'invitation', targetUserId: pendingUser.id, details: { email: inv.email, role: inv.role } });
res.json({ ok: true, userId: pendingUser.id });
} catch (e) { next(e); }