fix: verify user exists before returning existing apikey in usersync, clean stale downapikey records
This commit is contained in:
parent
09acce0637
commit
f1ed6ad151
@ -80,6 +80,13 @@ async with db.sqlorContext(dbname) as sor:
|
|||||||
})
|
})
|
||||||
|
|
||||||
if existing:
|
if existing:
|
||||||
|
# 验证用户是否存在
|
||||||
|
user_check = await sor.R('users', {'id': existing[0].userid})
|
||||||
|
if not user_check:
|
||||||
|
# 脏数据:downapikey 存在但用户已删除,清理后重新创建
|
||||||
|
await sor.D('downapikey', {'id': existing[0].id})
|
||||||
|
existing = None
|
||||||
|
else:
|
||||||
apikey = password_decode(existing[0].apikey)
|
apikey = password_decode(existing[0].apikey)
|
||||||
return json.dumps({
|
return json.dumps({
|
||||||
'status': 'success',
|
'status': 'success',
|
||||||
@ -169,6 +176,13 @@ async with db.sqlorContext(dbname) as sor:
|
|||||||
})
|
})
|
||||||
|
|
||||||
if existing:
|
if existing:
|
||||||
|
# 验证用户是否存在
|
||||||
|
user_check = await sor.R('users', {'id': existing[0].userid})
|
||||||
|
if not user_check:
|
||||||
|
# 脏数据,清理后重新创建
|
||||||
|
await sor.D('downapikey', {'id': existing[0].id})
|
||||||
|
existing = None
|
||||||
|
else:
|
||||||
apikey = password_decode(existing[0].apikey)
|
apikey = password_decode(existing[0].apikey)
|
||||||
result_data.append({
|
result_data.append({
|
||||||
'user_id': user_id,
|
'user_id': user_id,
|
||||||
@ -176,6 +190,7 @@ async with db.sqlorContext(dbname) as sor:
|
|||||||
'apikey': apikey,
|
'apikey': apikey,
|
||||||
'status': 'existing'
|
'status': 'existing'
|
||||||
})
|
})
|
||||||
|
continue
|
||||||
else:
|
else:
|
||||||
# 创建新apikey
|
# 创建新apikey
|
||||||
apikey_id = getID()
|
apikey_id = getID()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user