fix: deploy crash + multiple bug fixes + cleanup

- server.js: fix getSiteName() returning string when not installed causing
  'getSiteName(...).then is not a function' crash on homepage (deploy blocker)
- server.js: auto-load business routes after install completes (no restart needed),
  HTML cache keyed by api_key
- install: validate db name/email/password, trigger route loading after complete
- app.js: fix forgot/reset/verify pages rendering HomePage (missing page mapping)
- verify.js: support URL token auto-verification for external registration links
- auth: new email_code template for 6-digit code, reset_password template
  (forgot-password was using verify_email template)
- upload.js: fix MP4 magic-bytes check using undefined buf variable
- tickets.js: status enum validation, anonymous submission rate limit
- security.js: XSS whitelist preserves email template HTML, strips scripts,
  blocks javascript:/data: hrefs; CORS reject returns 403
- bans.js: allow clearing reason/duration, status enum validation
- users.js: fix req.user.role ReferenceError in create user modal
- home.js: tracking results now have detail view button
- .gitignore: ignore data/ (db credentials), logs, session files, temp scripts
This commit is contained in:
2026-08-16 21:21:25 +08:00
parent 64199a0aaf
commit 6e9101a506
15 changed files with 97 additions and 40 deletions

View File

@@ -12,6 +12,7 @@ router.get('/status', (req, res) => {
router.post('/check-db', async (req, res) => {
const { host, port, user, password, database } = req.body;
if (!/^[A-Za-z0-9_]+$/.test(database || '')) return res.status(400).json({ error: '数据库名仅允许字母、数字、下划线' });
try {
const conn = await mysql.createConnection({
host: host || 'localhost',
@@ -42,6 +43,9 @@ router.post('/complete', async (req, res) => {
if (!db_host || !db_user || !db_name || !admin_username || !admin_password || !admin_email) {
return res.status(400).json({ error: '必填字段不完整' });
}
if (!/^[A-Za-z0-9_]+$/.test(db_name || '')) return res.status(400).json({ error: '数据库名仅允许字母、数字、下划线' });
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(admin_email)) return res.status(400).json({ error: '邮箱格式不正确' });
if (admin_password.length < 6) return res.status(400).json({ error: '密码至少6位' });
try {
const conn = await mysql.createConnection({
@@ -90,7 +94,9 @@ router.post('/complete', async (req, res) => {
external_api_key: externalKey,
});
res.json({ ok: true, message: '安装完成,请重新启动服务器' });
try { if (typeof global.__loadBusinessRoutes === 'function') global.__loadBusinessRoutes(); } catch {}
res.json({ ok: true, message: '安装完成,无需重启,系统已就绪' });
} catch (e) {
res.status(500).json({ error: '安装失败: ' + e.message });
}