Compare commits

...
2 Commits
Author SHA1 Message Date
lik f0edd6d548 bug fixed 2026-10-07 15:51:23 +08:00
lik 1974975882 bug fixed 2026-10-07 15:51:02 +08:00
4 changed files with 10 additions and 39 deletions
+1
View File
@@ -1,3 +1,4 @@
/node_modules/ /node_modules/
/logs/ /logs/
conf.json conf.json
.env
+5
View File
@@ -20,6 +20,11 @@ class APP {
} }
setupMiddleware() { setupMiddleware() {
// 服务在 nginx 之后,需信任代理头才能拿到真实客户端 IP
// (否则 ctx.ip 恒为 127.0.0.1,限流会变成全站共享一个桶)
this.app.proxy = true;
this.app.proxyIpHeader = "X-Real-IP";
this.app.use(cors()); this.app.use(cors());
this.app.use(bodyParser()); this.app.use(bodyParser());
-28
View File
@@ -1,28 +0,0 @@
{
"port": 9010,
"app": {
"wxapp-escort": {
"appid": "wxf73c79e16837af07",
"secret": "5a061d65f4d35d19e62e83b98f6c63cf"
},
"wxapp-escort-admin": {
"appid": "wxf94dd97b91af09a2",
"secret": "79ba226684740830af0029763d3045f0"
}
},
"mongodb": {
"str": "mongodb://huashengtec.com:6000",
"host": "huashengtec.com",
"db": "health",
"option": {
"user": "ehason",
"pass": "Ehason_dbuser_2026",
"dbName": "eiot_user",
"authSource": "admin",
"autoIndex": true,
"socketTimeoutMS": 3000,
"serverSelectionTimeoutMS": 30000
},
"debug": true
}
}
+4 -11
View File
@@ -241,17 +241,10 @@ class HandlerUser {
return ResponseUtil.success(ctx, { user: sanitizeUser(ctx.state.user) }, "获取用户信息成功"); return ResponseUtil.success(ctx, { user: sanitizeUser(ctx.state.user) }, "获取用户信息成功");
} }
// 兼容:通过 userId 查询(脱敏响应,不含任何安全凭证) // 不再支持「凭 userId 明文查询」:用户ID不是凭证,
const { userId } = ctx.request.body || {}; // 任何人都可能通过日志/链接拿到他人 userId,若可据此读取资料即构成越权。
if (userId) { // 一律要求携带有效 token,身份以 token 为准。
const user = await DBModel.User.findOne({ _id: userId }); return ResponseUtil.badRequest(ctx, "缺少 token");
if (!user) {
return ResponseUtil.notFound(ctx, "用户不存在");
}
return ResponseUtil.success(ctx, { user: sanitizeUser(user) }, "获取用户信息成功");
}
return ResponseUtil.badRequest(ctx, "缺少 token 或 userId");
} }
// 更新用户信息 // 更新用户信息