debug: 添加详细的分享验证调试日志

## 调试内容
为了排查过期分享仍能访问的问题,添加了详细的调试日志:

### 1. database.js - ShareDB.findByCode()
- 记录调用时的参数和SQLite当前时间
- 记录SQL查询结果(是否找到、过期时间、分享类型)
- 便于对比JavaScript时间和SQLite时间

### 2. server.js - /api/share/:code/verify
- 记录请求时间戳、分享码、是否有密码、请求IP
- 记录findByCode的返回结果和过期状态

### 3. server.js - /api/share/:code/list
- 记录请求时间戳、分享码、子路径、密码状态
- 记录findByCode的返回结果和过期状态

## 使用方法
1. 管理员在管理后台开启调试模式
2. 访问分享链接 https://cs.workyai.cn/s/oSrhV9D3
3. 查看后端console日志输出

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-14 16:09:01 +08:00
parent bce225ec5c
commit eaf9ad7bb1
2 changed files with 56 additions and 1 deletions

View File

@@ -1582,8 +1582,26 @@ app.post('/api/share/:code/verify', shareRateLimitMiddleware, async (req, res) =
let storage;
try {
// ===== 调试日志: 分享验证开始 =====
console.log('[分享验证]', {
timestamp: new Date().toISOString(),
shareCode: code,
hasPassword: !!password,
requestIP: req.ip
});
const share = ShareDB.findByCode(code);
// 调试日志: findByCode 结果
console.log('[分享验证] findByCode结果:', {
found: !!share,
expires_at: share?.expires_at || null,
current_time: new Date().toISOString(),
is_expired: share?.expires_at ? new Date(share.expires_at) <= new Date() : false
});
if (!share) {
return res.status(404).json({
success: false,
@@ -1743,8 +1761,27 @@ app.post('/api/share/:code/list', shareRateLimitMiddleware, async (req, res) =>
let storage;
try {
// ===== 调试日志: 获取分享文件列表 =====
console.log('[获取文件列表]', {
timestamp: new Date().toISOString(),
shareCode: code,
subPath: subPath,
hasPassword: !!password,
requestIP: req.ip
});
const share = ShareDB.findByCode(code);
// 调试日志: findByCode 结果
console.log('[获取文件列表] findByCode结果:', {
found: !!share,
expires_at: share?.expires_at || null,
current_time: new Date().toISOString(),
is_expired: share?.expires_at ? new Date(share.expires_at) <= new Date() : false
});
if (!share) {
return res.status(404).json({
success: false,