mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 09:38:02 +00:00
chore: remove regenerate api key functionality
This commit is contained in:
@@ -253,42 +253,6 @@ router.post('/api-keys', authenticateUser, async (req, res) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 🔑 重新生成API Key
|
|
||||||
router.post('/api-keys/:keyId/regenerate', authenticateUser, async (req, res) => {
|
|
||||||
try {
|
|
||||||
const { keyId } = req.params
|
|
||||||
|
|
||||||
// 检查API Key是否属于当前用户
|
|
||||||
const existingKey = await apiKeyService.getApiKeyById(keyId)
|
|
||||||
if (!existingKey || existingKey.userId !== req.user.id) {
|
|
||||||
return res.status(404).json({
|
|
||||||
error: 'API key not found',
|
|
||||||
message: 'API key not found or you do not have permission to access it'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const newKey = await apiKeyService.regenerateApiKey(keyId)
|
|
||||||
|
|
||||||
logger.info(`🔄 User ${req.user.username} regenerated API key: ${existingKey.name}`)
|
|
||||||
|
|
||||||
res.json({
|
|
||||||
success: true,
|
|
||||||
message: 'API key regenerated successfully',
|
|
||||||
apiKey: {
|
|
||||||
id: newKey.id,
|
|
||||||
name: newKey.name,
|
|
||||||
key: newKey.key, // 返回新的key
|
|
||||||
updatedAt: newKey.updatedAt
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} catch (error) {
|
|
||||||
logger.error('❌ Regenerate user API key error:', error)
|
|
||||||
res.status(500).json({
|
|
||||||
error: 'API Key regeneration error',
|
|
||||||
message: 'Failed to regenerate API key'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// 🗑️ 删除API Key
|
// 🗑️ 删除API Key
|
||||||
router.delete('/api-keys/:keyId', authenticateUser, async (req, res) => {
|
router.delete('/api-keys/:keyId', authenticateUser, async (req, res) => {
|
||||||
|
|||||||
@@ -139,21 +139,6 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
|
||||||
class="inline-flex items-center rounded border border-transparent p-1 text-gray-400 hover:text-gray-600"
|
|
||||||
title="Regenerate API Key"
|
|
||||||
@click="regenerateApiKey(apiKey)"
|
|
||||||
>
|
|
||||||
<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path
|
|
||||||
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
stroke-width="2"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="inline-flex items-center rounded border border-transparent p-1 text-red-400 hover:text-red-600"
|
class="inline-flex items-center rounded border border-transparent p-1 text-red-400 hover:text-red-600"
|
||||||
title="Delete API Key"
|
title="Delete API Key"
|
||||||
@@ -293,29 +278,6 @@ const showApiKey = (apiKey) => {
|
|||||||
showViewModal.value = true
|
showViewModal.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const regenerateApiKey = async (apiKey) => {
|
|
||||||
try {
|
|
||||||
const result = await userStore.regenerateApiKey(apiKey.id)
|
|
||||||
|
|
||||||
if (result.success) {
|
|
||||||
showToast('API key regenerated successfully', 'success')
|
|
||||||
|
|
||||||
// 显示新的API key
|
|
||||||
selectedApiKey.value = {
|
|
||||||
...apiKey,
|
|
||||||
key: result.apiKey.key
|
|
||||||
}
|
|
||||||
showViewModal.value = true
|
|
||||||
|
|
||||||
// 重新加载列表
|
|
||||||
await loadApiKeys()
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to regenerate API key:', error)
|
|
||||||
showToast('Failed to regenerate API key', 'error')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const deleteApiKey = (apiKey) => {
|
const deleteApiKey = (apiKey) => {
|
||||||
selectedApiKey.value = apiKey
|
selectedApiKey.value = apiKey
|
||||||
showDeleteModal.value = true
|
showDeleteModal.value = true
|
||||||
|
|||||||
@@ -139,17 +139,6 @@ export const useUserStore = defineStore('user', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 🔄 重新生成API Key
|
|
||||||
async regenerateApiKey(keyId) {
|
|
||||||
try {
|
|
||||||
const response = await axios.post(`${API_BASE}/api-keys/${keyId}/regenerate`)
|
|
||||||
return response.data
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to regenerate API key:', error)
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// 🗑️ 删除API Key
|
// 🗑️ 删除API Key
|
||||||
async deleteApiKey(keyId) {
|
async deleteApiKey(keyId) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user