Gestion des utilisateurs

This commit is contained in:
ocroguennec committed 2026-06-15 07:32:36 +02:00
1 parent 414c8dbb74
commit f3c5387a92
11 files changed
+1163 -128

No files matched your search

+8 -1
View File
@@ -101,13 +101,20 @@ router.post('/login', async (req, res, next) => {
try {
const body = LoginSchema2FA.parse(req.body);
const user = db
.prepare('SELECT id, email, password_hash, display_name, role, email_verified, totp_enabled FROM users WHERE email = ?')
.prepare('SELECT id, email, password_hash, display_name, role, email_verified, totp_enabled, status FROM users WHERE email = ?')
.get(body.email);
if (!user) throw new HttpError(401, 'Invalid credentials');
const ok = bcrypt.compareSync(body.password, user.password_hash);
if (!ok) throw new HttpError(401, 'Invalid credentials');
if (user.status === 'deactivated') {
return res.status(403).json({ error: 'Ce compte a été désactivé. Contactez un administrateur.', code: 'ACCOUNT_DEACTIVATED' });
}
if (user.status === 'locked') {
return res.status(403).json({ error: 'Ce compte est verrouillé. Contactez un administrateur.', code: 'ACCOUNT_LOCKED' });
}
if (!user.email_verified) {
return res.status(403).json({
error: 'Veuillez vérifier votre adresse email avant de vous connecter.',