mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
fix: 修复droid账号更新丢失apikey的问题
This commit is contained in:
@@ -782,6 +782,8 @@ class DroidAccountService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const storedAccount = await redis.getDroidAccount(accountId)
|
const storedAccount = await redis.getDroidAccount(accountId)
|
||||||
|
const hasStoredAccount =
|
||||||
|
storedAccount && typeof storedAccount === 'object' && Object.keys(storedAccount).length > 0
|
||||||
const sanitizedUpdates = { ...updates }
|
const sanitizedUpdates = { ...updates }
|
||||||
|
|
||||||
if (typeof sanitizedUpdates.accessToken === 'string') {
|
if (typeof sanitizedUpdates.accessToken === 'string') {
|
||||||
@@ -905,7 +907,7 @@ class DroidAccountService {
|
|||||||
|
|
||||||
// 使用 Redis 中的原始数据获取加密的 API Key 条目
|
// 使用 Redis 中的原始数据获取加密的 API Key 条目
|
||||||
const existingApiKeyEntries = this._parseApiKeyEntries(
|
const existingApiKeyEntries = this._parseApiKeyEntries(
|
||||||
storedAccount && Object.prototype.hasOwnProperty.call(storedAccount, 'apiKeys')
|
hasStoredAccount && Object.prototype.hasOwnProperty.call(storedAccount, 'apiKeys')
|
||||||
? storedAccount.apiKeys
|
? storedAccount.apiKeys
|
||||||
: ''
|
: ''
|
||||||
)
|
)
|
||||||
@@ -957,13 +959,29 @@ class DroidAccountService {
|
|||||||
encryptedUpdates.accessToken = this._encryptSensitiveData(sanitizedUpdates.accessToken)
|
encryptedUpdates.accessToken = this._encryptSensitiveData(sanitizedUpdates.accessToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const baseAccountData = hasStoredAccount ? { ...storedAccount } : { id: accountId }
|
||||||
|
|
||||||
const updatedData = {
|
const updatedData = {
|
||||||
...account,
|
...baseAccountData,
|
||||||
...encryptedUpdates,
|
...encryptedUpdates
|
||||||
refreshToken:
|
}
|
||||||
encryptedUpdates.refreshToken || this._encryptSensitiveData(account.refreshToken),
|
|
||||||
accessToken: encryptedUpdates.accessToken || this._encryptSensitiveData(account.accessToken),
|
if (!Object.prototype.hasOwnProperty.call(updatedData, 'refreshToken')) {
|
||||||
proxy: encryptedUpdates.proxy
|
updatedData.refreshToken =
|
||||||
|
hasStoredAccount && Object.prototype.hasOwnProperty.call(storedAccount, 'refreshToken')
|
||||||
|
? storedAccount.refreshToken
|
||||||
|
: this._encryptSensitiveData(account.refreshToken)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(updatedData, 'accessToken')) {
|
||||||
|
updatedData.accessToken =
|
||||||
|
hasStoredAccount && Object.prototype.hasOwnProperty.call(storedAccount, 'accessToken')
|
||||||
|
? storedAccount.accessToken
|
||||||
|
: this._encryptSensitiveData(account.accessToken)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(updatedData, 'proxy')) {
|
||||||
|
updatedData.proxy = hasStoredAccount ? storedAccount.proxy || '' : account.proxy || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
await redis.setDroidAccount(accountId, updatedData)
|
await redis.setDroidAccount(accountId, updatedData)
|
||||||
|
|||||||
@@ -3160,6 +3160,15 @@ const parseProxyResponse = (rawProxy) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
proxyObject &&
|
||||||
|
typeof proxyObject === 'object' &&
|
||||||
|
proxyObject.proxy &&
|
||||||
|
typeof proxyObject.proxy === 'object'
|
||||||
|
) {
|
||||||
|
proxyObject = proxyObject.proxy
|
||||||
|
}
|
||||||
|
|
||||||
if (!proxyObject || typeof proxyObject !== 'object') {
|
if (!proxyObject || typeof proxyObject !== 'object') {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2488,7 +2488,7 @@ const filterByGroup = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 规范化代理配置,支持字符串与对象
|
// 规范化代理配置,支持字符串与对象
|
||||||
const normalizeProxyData = (proxy) => {
|
function normalizeProxyData(proxy) {
|
||||||
if (!proxy) {
|
if (!proxy) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user