A lot of code clean up! Also adding in Response everywhere...

This commit is contained in:
Scott Idem
2021-08-10 18:09:34 -04:00
parent 73466456ee
commit d933395a9f
57 changed files with 290 additions and 147 deletions

View File

@@ -1,5 +1,5 @@
import datetime, pytz, secrets, time
from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, status
from fastapi import APIRouter, Body, Depends, Header, HTTPException, Query, Response, status
from pydantic import BaseModel, EmailStr, Field
from typing import Dict, List, Optional, Set, Union
@@ -100,7 +100,7 @@ async def change_user_obj_password(
password = secrets.token_urlsafe(default_num_bytes)
if user_id := redis_lookup_id_random(record_id_random=user_id, table_name='user'): pass
else: return mk_resp(data=False, status_code=404) # Not Found
else: return mk_resp(data=False, status_code=404, response=response) # Not Found
user_data = {}
#user_data['user_id'] = user_id
@@ -188,7 +188,7 @@ async def user_new_auth_key(
log.info('The user record was not updated with a new auth_key')
log.debug(user_rec_update_result)
return mk_resp(data=False, status_code=404)
return mk_resp(data=False, status_code=404, response=response)
# ### BEGIN ### API User Routers ### user_authenticate() ###
@@ -215,7 +215,7 @@ async def user_authenticate(
if account_id and username and password:
if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass
else: return mk_resp(data=False, status_code=404) # Not Found
else: return mk_resp(data=False, status_code=404, response=response) # Not Found
user_data = {}
user_data['account_id'] = account_id
@@ -351,7 +351,7 @@ async def lookup_user_obj(
base_name = User_Out_Base
if for_obj_id := redis_lookup_id_random(record_id_random=for_obj_id, table_name=for_obj_type): pass
else: return mk_resp(data=False, status_code=404) # Not Found
else: return mk_resp(data=False, status_code=404, response=response) # Not Found
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
data = {}
@@ -429,7 +429,7 @@ async def lookup_email(
elif account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'):
pass
else:
return mk_resp(data=False, status_code=404) # Not Found
return mk_resp(data=False, status_code=404, response=response) # Not Found
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
data = {}
@@ -506,7 +506,7 @@ async def lookup_username(
elif account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'):
pass
else:
return mk_resp(data=False, status_code=404) # Not Found
return mk_resp(data=False, status_code=404, response=response) # Not Found
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
data = {}