fix: resolve final audit issues

- firmware route: extract insertId from ResultSetHeader correctly
- admin device detail: add null check and flatten response to match
  frontend's expected field structure
- device command result: add ownership verification before finishing
  command (security fix)
这个提交包含在:
Guoguo
2026-04-29 06:02:18 -07:00
父节点 bb4b80f867
当前提交 62a63f9c9b
修改 3 个文件,包含 7 行新增6 行删除
+2 -2
查看文件
@@ -110,8 +110,8 @@ router.post('/devices/batch', requireAdmin, wrap(async (req, res) => {
router.get('/devices/:device_id', requireAdmin, wrap(async (req, res) => {
const result = await deviceDao.findByIdWithHistory(req.params.device_id)
if (!result) return res.json(fail(1005, 'DEVICE_NOT_FOUND'))
res.json(ok(result))
if (!result || !result.device) return res.json(fail(1005, 'DEVICE_NOT_FOUND'))
res.json(ok(Object.assign({}, result.device, { binding_history: result.binding_history, recent_treatments: result.recent_treatments })))
}))
router.post('/devices/:device_id/unbind', requireAdmin, wrap(async (req, res) => {