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:
@@ -333,13 +333,31 @@ const ShareDB = {
|
||||
|
||||
// 根据分享码查找
|
||||
findByCode(shareCode) {
|
||||
return db.prepare(`
|
||||
// 调试日志: findByCode 调用
|
||||
const currentTime = db.prepare("SELECT datetime('now') as now").get();
|
||||
console.log('[ShareDB.findByCode]', {
|
||||
shareCode,
|
||||
currentTime: currentTime.now,
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
|
||||
const result = db.prepare(`
|
||||
SELECT s.*, u.username, u.ftp_host, u.ftp_port, u.ftp_user, u.ftp_password, u.http_download_base_url
|
||||
FROM shares s
|
||||
JOIN users u ON s.user_id = u.id
|
||||
WHERE s.share_code = ?
|
||||
AND (s.expires_at IS NULL OR s.expires_at > datetime('now'))
|
||||
`).get(shareCode);
|
||||
|
||||
// 调试日志: SQL查询结果
|
||||
console.log('[ShareDB.findByCode] SQL结果:', {
|
||||
found: !!result,
|
||||
shareCode: result?.share_code || null,
|
||||
expires_at: result?.expires_at || null,
|
||||
share_type: result?.share_type || null
|
||||
});
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
// 根据ID查找
|
||||
|
||||
Reference in New Issue
Block a user