From dc5de6e63aaeec91cd196e32605dca4c469a1741 Mon Sep 17 00:00:00 2001 From: Sunwuyuan Date: Sun, 1 Feb 2026 19:09:59 +0800 Subject: [PATCH] fix: standardize autoAuth field names to autoauth in apps and auto-auth routes --- routes/apps.js | 8 ++++---- routes/auto-auth.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/routes/apps.js b/routes/apps.js index 4d3b295..d70b1c6 100644 --- a/routes/apps.js +++ b/routes/apps.js @@ -179,7 +179,7 @@ router.post( const device = await prisma.device.findUnique({ where: {namespace}, include: { - autoAuths: true, + autoauths: true, }, }); @@ -193,11 +193,11 @@ router.post( // 如果提供了密码,查找匹配密码的自动授权 if (password) { // 首先尝试直接匹配明文密码 - matchedAutoAuth = device.autoAuths.find(auth => auth.password === password); + matchedAutoAuth = device.autoauths.find(auth => auth.password === password); // 如果没有匹配到,尝试验证哈希密码(向后兼容) if (!matchedAutoAuth) { - for (const autoAuth of device.autoAuths) { + for (const autoAuth of device.autoauths) { if (autoAuth.password && autoAuth.password.startsWith('$2')) { // bcrypt 哈希以 $2 开头 try { if (await verifyDevicePassword(password, autoAuth.password)) { @@ -225,7 +225,7 @@ router.post( } } else { // 如果没有提供密码,查找密码为空的自动授权 - matchedAutoAuth = device.autoAuths.find(auth => !auth.password); + matchedAutoAuth = device.autoauths.find(auth => !auth.password); if (!matchedAutoAuth) { return next(errors.createError(401, "需要提供密码")); diff --git a/routes/auto-auth.js b/routes/auto-auth.js index 9de9b49..a1d2963 100644 --- a/routes/auto-auth.js +++ b/routes/auto-auth.js @@ -30,13 +30,13 @@ router.get( return next(errors.createError(403, "该设备未绑定到您的账户")); } - const autoAuths = await prisma.autoAuth.findMany({ + const autoauths = await prisma.autoAuth.findMany({ where: {deviceid: device.id}, orderBy: {createdat: 'desc'}, }); // 返回配置,智能处理密码显示 - const configs = autoAuths.map(auth => { + const configs = autoauths.map(auth => { // 检查是否是 bcrypt 哈希密码 const isHashedPassword = auth.password && auth.password.startsWith('$2');