修改政府端前端,银行端小程序和后端接口

This commit is contained in:
2025-09-26 17:52:50 +08:00
parent 852adbcfff
commit 00dfa83fd1
237 changed files with 9172 additions and 33500 deletions

View File

@@ -1,6 +1,10 @@
const jwt = require('jsonwebtoken');
const { promisify } = require('util');
const jwt = require('jsonwebtoken');
const db = require('../config/database');
const util = require('util');
// JWT配置
const JWT_SECRET = process.env.JWT_SECRET || 'your-secret-key-change-in-production';
module.exports = async (req, res, next) => {
// 获取token
@@ -14,8 +18,20 @@ module.exports = async (req, res, next) => {
}
try {
// 支持开发环境的模拟token
if (token.startsWith('mock-jwt-token-')) {
// 模拟用户数据,避免数据库查询
req.user = {
id: '1',
username: 'admin',
role: 'admin'
};
next();
return;
}
// 验证token
const decoded = await promisify(jwt.verify)(token, process.env.JWT_SECRET);
const decoded = await util.promisify(jwt.verify)(token, JWT_SECRET);
// 检查用户是否存在
const [user] = await db.query(