fix: verify user exists before returning existing apikey in create_user_apikey
This commit is contained in:
parent
5fc90a8033
commit
b2369cd00c
@ -227,6 +227,13 @@ async def create_user_apikey(sor, dappid, user_id, user_orgid, **kwargs):
|
|||||||
})
|
})
|
||||||
|
|
||||||
if existing:
|
if existing:
|
||||||
|
# 验证关联的 users 记录是否仍然存在
|
||||||
|
user_records = await sor.R('users', {'id': existing[0].userid})
|
||||||
|
if not user_records:
|
||||||
|
# downapikey 有记录但 users 表无对应用户(脏数据),清理后重新创建
|
||||||
|
debug(f'create_user_apikey: downapikey exists but user {existing[0].userid} not found, recreating')
|
||||||
|
await sor.D('downapikey', {'id': existing[0].id})
|
||||||
|
else:
|
||||||
# 返回现有apikey
|
# 返回现有apikey
|
||||||
f = get_serverenv('password_decode')
|
f = get_serverenv('password_decode')
|
||||||
apikey = f(existing[0].apikey)
|
apikey = f(existing[0].apikey)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user