fix security and import validation

This commit is contained in:
lizhilun
2026-07-01 16:13:47 +08:00
parent 6467048f38
commit e69930799c
14 changed files with 498 additions and 163 deletions
+7 -2
View File
@@ -1,5 +1,4 @@
const Database = require('better-sqlite3');
const bcrypt = require('bcryptjs');
const path = require('path');
const logger = require('./utils/logger');
@@ -108,11 +107,17 @@ function migrateAddRebateColumn() {
* 初始化默认用户
*/
function initDefaultUser() {
if (process.env.NODE_ENV === 'production') {
logger.info('生产环境跳过默认用户初始化');
return;
}
const existingUser = db.prepare('SELECT id FROM users WHERE username = ?').get('lizhilun');
if (!existingUser) {
const bcrypt = require('bcryptjs');
const hash = bcrypt.hashSync('lizhilun', 10);
db.prepare('INSERT INTO users (username, password) VALUES (?, ?)').run('lizhilun', hash);
logger.info('默认用户 lizhilun 已创建');
logger.info('开发默认用户 lizhilun 已创建');
}
}