fix(auth): handle list response from sql_select in dependencies_v3
- Check if api_key_results is a list before calling .get() - Prevents 500 AttributeError on machine auth verification
This commit is contained in:
@@ -34,7 +34,10 @@ def get_account_context_optional(
|
||||
# This identifies the script/app, regardless of the user/account context.
|
||||
if x_aether_api_key:
|
||||
sql = "SELECT * FROM api_key WHERE (public_key = :key OR secret_key = :key) LIMIT 1"
|
||||
if api_key_rec := sql_select(sql=sql, data={'key': x_aether_api_key}):
|
||||
if api_key_results := sql_select(sql=sql, data={'key': x_aether_api_key}):
|
||||
# sql_select returns a list when raw SQL is used
|
||||
api_key_rec = api_key_results[0] if isinstance(api_key_results, list) else api_key_results
|
||||
|
||||
if api_key_rec.get('enable'):
|
||||
now = datetime.now()
|
||||
enable_from = api_key_rec.get('enable_from')
|
||||
|
||||
Reference in New Issue
Block a user