fix: user stats

This commit is contained in:
Feng Yue
2025-08-13 22:34:22 +08:00
parent a3c9e39401
commit 2756671117
5 changed files with 235 additions and 165 deletions

View File

@@ -492,8 +492,8 @@ class ApiKeyService {
try {
const allKeys = await redis.getAllApiKeys()
return allKeys
.filter(key => key.userId === userId)
.map(key => ({
.filter((key) => key.userId === userId)
.map((key) => ({
id: key.id,
name: key.name,
description: key.description,
@@ -520,7 +520,9 @@ class ApiKeyService {
async getApiKeyById(keyId, userId = null) {
try {
const keyData = await redis.getApiKey(keyId)
if (!keyData) return null
if (!keyData) {
return null
}
// 如果指定了用户ID检查权限
if (userId && keyData.userId !== userId) {