fix: use dappid+userid for downapikey query/insert, matching actual table schema
This commit is contained in:
parent
f313877f4b
commit
cd82b345aa
@ -57,8 +57,8 @@ async with db.sqlorContext(dbname) as sor:
|
||||
except Exception as e:
|
||||
exception(f"Failed to open accounts: {e}")
|
||||
|
||||
# 2. 处理 Apikey — 按用户级(dappid+duserid+dorgid)查询
|
||||
existing = await sor.R('downapikey', {'dappid': dappid, 'duserid': user_id, 'dorgid': user_orgid})
|
||||
# 2. 处理 Apikey — 按(dappid, userid)查询
|
||||
existing = await sor.R('downapikey', {'dappid': dappid, 'userid': user_id})
|
||||
|
||||
if existing:
|
||||
apikey = password_decode(existing[0].apikey)
|
||||
@ -66,9 +66,9 @@ async with db.sqlorContext(dbname) as sor:
|
||||
else:
|
||||
apikey_value = getID()
|
||||
ns_key = {
|
||||
'id': getID(), 'dappid': dappid, 'dorgid': user_orgid, 'duserid': user_id,
|
||||
'orgid': user_orgid, 'userid': user_id, 'apikey': password_encode(apikey_value),
|
||||
'enabled': '1', 'created_at': datetime.now().strftime('%Y-%m-%d'), 'expired_date': '9999-12-31'
|
||||
'id': getID(), 'dappid': dappid, 'userid': user_id,
|
||||
'apikey': password_encode(apikey_value),
|
||||
'enabled_date': datetime.now().strftime('%Y-%m-%d'), 'expired_date': '9999-12-31'
|
||||
}
|
||||
await sor.C('downapikey', ns_key)
|
||||
apikey = apikey_value
|
||||
@ -120,17 +120,17 @@ async with db.sqlorContext(dbname) as sor:
|
||||
except Exception as e:
|
||||
exception(f"Failed to open accounts: {e}")
|
||||
|
||||
# 2. 处理 Apikey — 按用户级(dappid+duserid+dorgid)查询
|
||||
existing = await sor.R('downapikey', {'dappid': dappid, 'duserid': user_id, 'dorgid': user_orgid})
|
||||
# 2. 处理 Apikey — 按(dappid, userid)查询
|
||||
existing = await sor.R('downapikey', {'dappid': dappid, 'userid': user_id})
|
||||
if existing:
|
||||
apikey = password_decode(existing[0].apikey)
|
||||
status_msg = '用户已同步'
|
||||
else:
|
||||
apikey_value = getID()
|
||||
ns_key = {
|
||||
'id': getID(), 'dappid': dappid, 'dorgid': user_orgid, 'duserid': user_id,
|
||||
'orgid': user_orgid, 'userid': user_id, 'apikey': password_encode(apikey_value),
|
||||
'enabled': '1', 'created_at': datetime.now().strftime('%Y-%m-%d'), 'expired_date': '9999-12-31'
|
||||
'id': getID(), 'dappid': dappid, 'userid': user_id,
|
||||
'apikey': password_encode(apikey_value),
|
||||
'enabled_date': datetime.now().strftime('%Y-%m-%d'), 'expired_date': '9999-12-31'
|
||||
}
|
||||
await sor.C('downapikey', ns_key)
|
||||
apikey = apikey_value
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user