Modification des pages d'authentification
This commit is contained in:
@@ -48,13 +48,24 @@ const router = Router();
|
||||
/** Liste tous les utilisateurs */
|
||||
router.get('/users', (req, res) => {
|
||||
const users = db.prepare(`
|
||||
SELECT id, email, display_name, role, created_at
|
||||
SELECT id, email, display_name, role, email_verified, created_at
|
||||
FROM users
|
||||
ORDER BY id ASC
|
||||
`).all();
|
||||
res.json(users);
|
||||
});
|
||||
|
||||
/** Vérifier manuellement l'email d'un utilisateur */
|
||||
router.patch('/users/:id/verify-email', (req, res, next) => {
|
||||
try {
|
||||
const targetId = Number(req.params.id);
|
||||
const r = db.prepare("UPDATE users SET email_verified=1, updated_at=datetime('now') WHERE id=?").run(targetId);
|
||||
if (r.changes === 0) throw new HttpError(404, 'Utilisateur introuvable');
|
||||
db.prepare('UPDATE email_verification_tokens SET used=1 WHERE user_id=? AND used=0').run(targetId);
|
||||
res.json({ ok: true });
|
||||
} catch (e) { next(e); }
|
||||
});
|
||||
|
||||
/** Crée un utilisateur */
|
||||
const CreateUserSchema = z.object({
|
||||
email: z.string().email(),
|
||||
@@ -387,7 +398,7 @@ router.get('/smtp', (req, res) => {
|
||||
username: row.username || '',
|
||||
hasPassword: !!(row.password),
|
||||
allowUnauth: !!row.allow_unauth,
|
||||
appName: row.app_name || 'Crowdlending',
|
||||
appName: row.app_name || 'Crowdlending Tracker',
|
||||
appUrl: row.app_url || '',
|
||||
});
|
||||
});
|
||||
@@ -450,7 +461,7 @@ router.put('/smtp', (req, res, next) => {
|
||||
body.username ?? null,
|
||||
passwordToStore,
|
||||
body.allowUnauth ? 1 : 0,
|
||||
body.appName ?? 'Crowdlending',
|
||||
body.appName ?? 'Crowdlending Tracker',
|
||||
body.appUrl ?? '',
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user