修复创建HR账号400: SQL内"hr"双引号字面量在新版SQLite不再宽容(全文扫描仅此一处), 改单引号

This commit is contained in:
mzl92
2026-08-27 16:27:07 +08:00
parent 932781a55e
commit 26d20fd3d4
+1 -1
View File
@@ -260,7 +260,7 @@ app.post('/api/users', requireAuth, requireSuper, (req, res) => {
const { username, password } = req.body || {}; const { username, password } = req.body || {};
if (!username || !password || String(password).length < 6) return res.status(400).json({ error: '用户名必填,密码至少6位' }); if (!username || !password || String(password).length < 6) return res.status(400).json({ error: '用户名必填,密码至少6位' });
try { try {
const info = udb.prepare('INSERT INTO users (username, password, role) VALUES (?, ?, "hr")') const info = udb.prepare("INSERT INTO users (username, password, role) VALUES (?, ?, 'hr')")
.run(String(username).trim(), hashPassword(String(password))); .run(String(username).trim(), hashPassword(String(password)));
logAccess(req, req.user.username, 'user_create', `创建 ${String(username).trim()}`); logAccess(req, req.user.username, 'user_create', `创建 ${String(username).trim()}`);
res.json({ ok: true, id: info.lastInsertRowid }); res.json({ ok: true, id: info.lastInsertRowid });