fix: HIGH+MEDIUM bugs from full audit - listen error, JWT, upload, mailer, webhook

This commit is contained in:
2026-07-13 03:49:02 +08:00
parent 7c03fe7635
commit 532efb962f
8 changed files with 56 additions and 29 deletions

View File

@@ -4,8 +4,13 @@ const { getConfig } = require('../db');
function getSecret() {
try {
const cfg = getConfig();
return cfg?.jwt_secret || process.env.JWT_SECRET || 'mc-dev-secret';
} catch { return process.env.JWT_SECRET || 'mc-dev-secret'; }
const secret = cfg?.jwt_secret || process.env.JWT_SECRET;
if (secret) return secret;
throw new Error('JWT_SECRET not configured');
} catch (e) {
if (e.message === 'JWT_SECRET not configured') throw e;
return process.env.JWT_SECRET || (() => { throw new Error('JWT_SECRET not configured'); })();
}
}
function generateToken(user) {