Audit activité utilisateurs
This commit is contained in:
@@ -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); }
|
||||
|
||||
Reference in New Issue
Block a user