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:
@@ -5,7 +5,7 @@ const { authenticate, requireRole, optionalAuth } = require('../middleware/auth'
|
||||
const { upload, finalizeUpload } = require('../middleware/upload');
|
||||
const { sendEmail } = require('../mailer');
|
||||
const { sendWebhook } = require('../webhook');
|
||||
const { validateLengths } = require('../middleware/security');
|
||||
const { validateLengths, ticketAnonLimiter } = require('../middleware/security');
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@@ -101,7 +101,7 @@ router.get('/:id', authenticate, async (req, res) => {
|
||||
res.json(t);
|
||||
});
|
||||
|
||||
router.post('/', optionalAuth, upload.array('files', 5), finalizeUpload, validateLengths({
|
||||
router.post('/', ticketAnonLimiter, optionalAuth, upload.array('files', 5), finalizeUpload, validateLengths({
|
||||
title:100, reporter_game_name:50, reporter_game_uid:50, target_game_name:50, target_game_uid:50, reason:300, description:5000,
|
||||
}), async (req, res) => {
|
||||
const { type, title, reporter_game_name, reporter_game_uid, target_game_name, target_game_uid, reason, description, is_admin_complaint, parent_ticket_id } = req.body;
|
||||
@@ -185,7 +185,10 @@ router.put('/:id', authenticate, requireRole('owner','admin'), async (req, res)
|
||||
if (req.user.role === 'admin' && t.assigned_to && t.assigned_to !== req.user.id) return res.status(403).json({ error: '只能修改自己负责的工单' });
|
||||
if (t.status === 'closed' && req.user.role !== 'owner') return res.status(400).json({ error: '已关闭的工单仅服主可操作' });
|
||||
const fields = {};
|
||||
if (req.body.status) fields.status = req.body.status;
|
||||
if (req.body.status) {
|
||||
if (!['pending','processing','awaiting_info','appealing','resolved','rejected','closed'].includes(req.body.status)) return res.status(400).json({ error: '无效的状态值' });
|
||||
fields.status = req.body.status;
|
||||
}
|
||||
if (req.body.priority) fields.priority = req.body.priority;
|
||||
if (req.body.priority && !['low','medium','high','urgent'].includes(req.body.priority)) return res.status(400).json({ error: '无效的优先级' });
|
||||
if (req.body.claim_note !== undefined) fields.claim_note = req.body.claim_note;
|
||||
|
||||
Reference in New Issue
Block a user