mirror of
https://github.com/margrop/wrong-notebook.git
synced 2026-12-02 14:39:37 +08:00
将 error-items 领域全部 19 个路由的样板鉴权代码(getServerSession / getCurrentUser → 查用户 → 401)替换为 withUser 包装器: - 删除 getServerSession、getCurrentUser、authOptions 的 import 和调用 - 删除 prisma.user.findUnique 查用户和 if (!user) return unauthorized 判空 - 删除鉴权专用的 try/catch 层 - 已有 withRecoverableResponse 的路由保持组合方式不变(外层) - 保留所有业务 try/catch 及特定错误文案/状态码 测试中允许的文案断言修改: - stats.test.ts 中 DELETE /api/error-items/clear 的 401 文案 从 'Unauthorized' 统一为 'Authentication required' - stats.test.ts 补充 mockPrismaUser(withUser 内部需要 prisma.user.findUnique)