Some general clean up and updates.

This commit is contained in:
Scott Idem
2021-08-23 12:36:30 -04:00
parent 824bdd29a2
commit e281b1d385
2 changed files with 9 additions and 8 deletions

View File

@@ -19,19 +19,19 @@ async def get_token_header(x_token:str = Header(...)):
# ### BEGIN ### API Lib General ### async get_account_header() ###
# Updated 2021-08-23
async def get_account_header(x_account_id:str = Header(...)):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARN, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
if len(x_account_id):
log.info('The x-account-id header has a value.')
log.info(f'The x-account-id header has a value. x-account-id: {x_account_id}')
if account_id := redis_lookup_id_random(table_name='account', record_id_random=x_account_id):
log.setLevel(logging.DEBUG)
log.info('Found the account_id with the account_id_random value: '+x_account_id)
account = { 'id': account_id, 'id_random': x_account_id }
else:
log.setLevel(logging.DEBUG)
log.info('The x-account-id was invalid and not empty...')
log.warning('The x-account-id Account ID was not found or it was invalid...')
#raise HTTPException(status_code=500)
raise HTTPException(status_code=400) # or 404?
#return False
@@ -40,7 +40,6 @@ async def get_account_header(x_account_id:str = Header(...)):
account = { 'id': None, 'id_random': None }
#account = { 'id': 0, 'id_random': 'abcdef123456' }
return account
# ### END ### API Lib General ### async get_account_header() ###