A lot of route common params clean up
This commit is contained in:
@@ -89,7 +89,7 @@ async def v3_post_person_obj_new(
|
||||
log.debug(locals())
|
||||
|
||||
if create_update_person_obj_result := create_update_person_obj_v4b(
|
||||
account_id = x_account['id'],
|
||||
account_id = commons.x_account_id,
|
||||
person_dict_obj = person_obj,
|
||||
person_id = None,
|
||||
# process_contact = process_contact,
|
||||
@@ -153,7 +153,7 @@ async def v3_patch_person_obj_exist(
|
||||
else: return mk_resp(data=None, status_code=404, response=commons.response, status_message='The person was not updated. The person ID was invalid or not found.')
|
||||
|
||||
if create_update_person_obj_result := create_update_person_obj_v4b(
|
||||
account_id = x_account['id'],
|
||||
account_id = commons.x_account_id,
|
||||
person_dict_obj = person_obj,
|
||||
person_id = person_id,
|
||||
# process_contact = process_contact,
|
||||
@@ -208,7 +208,7 @@ async def post_person_json(
|
||||
log.debug(locals())
|
||||
|
||||
if person_obj_in_result := create_update_person_obj_v4b(
|
||||
account_id = x_account['id'],
|
||||
account_id = commons.x_account_id,
|
||||
person_dict_obj = person_obj,
|
||||
person_id = None,
|
||||
process_contact = process_contact,
|
||||
@@ -246,7 +246,7 @@ async def patch_person_json(
|
||||
else: return mk_resp(data=None, status_code=404, response=commons.response)
|
||||
|
||||
if person_obj_up_result := create_update_person_obj_v4b(
|
||||
account_id = x_account['id'],
|
||||
account_id = commons.x_account_id,
|
||||
person_dict_obj = person_obj,
|
||||
process_contact = process_contact,
|
||||
process_organization = process_organization,
|
||||
@@ -290,7 +290,6 @@ async def get_person_obj_li(
|
||||
# Updated 2021-08-19
|
||||
@router.get('/person/external_id', response_model=Resp_Body_Base)
|
||||
async def person_obj_external_id(
|
||||
account_id: str = Query(..., min_length=1, max_length=22),
|
||||
external_id: str = Query(..., min_length=1, max_length=75),
|
||||
inc_address: bool = False,
|
||||
inc_contact: bool = False,
|
||||
@@ -302,8 +301,7 @@ async def person_obj_external_id(
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass
|
||||
else: return mk_resp(data=None, status_code=404, response=commons.response)
|
||||
account_id = commons.x_account_id
|
||||
# account_id = 99 # WARNING!!!! Get rid of 99!
|
||||
|
||||
if person_data := get_person_rec_w_external_id(account_id=account_id, external_id=external_id): pass
|
||||
@@ -345,8 +343,7 @@ async def lookup_email(
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if account_id := redis_lookup_id_random(record_id_random=x_account['id'], table_name='account'): pass
|
||||
else: return mk_resp(data=None, status_code=404, response=commons.response)
|
||||
account_id = commons.x_account_id
|
||||
|
||||
# import time
|
||||
|
||||
@@ -402,8 +399,7 @@ async def email_auth_key_url(
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if account_id := redis_lookup_id_random(record_id_random=x_account['id'], table_name='account'): pass
|
||||
else: return mk_resp(data=False, status_code=404, response=commons.response) # Not Found
|
||||
account_id = commons.x_account_id
|
||||
|
||||
if person_id := redis_lookup_id_random(record_id_random=person_id, table_name='person'): pass
|
||||
else: return mk_resp(data=False, status_code=404, response=commons.response) # Not Found
|
||||
|
||||
@@ -208,7 +208,7 @@ async def user_new_auth_key(
|
||||
# Updated 2021-10-06
|
||||
@router.get('/user/authenticate', response_model=Resp_Body_Base)
|
||||
async def user_authenticate(
|
||||
account_id: Optional[Union[int,str]] = None,
|
||||
null_account_id: bool = False,
|
||||
user_id: Optional[str] = Query(None, min_length=11, max_length=22),
|
||||
username: Optional[str] = Query(None, min_length=3, max_length=50),
|
||||
password: Optional[str] = Query(None, min_length=8, max_length=100),
|
||||
@@ -224,8 +224,7 @@ async def user_authenticate(
|
||||
log.debug(locals())
|
||||
|
||||
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, response=commons.response) # Not Found
|
||||
account_id = commons.x_account_id
|
||||
|
||||
user_data = {}
|
||||
user_data['account_id'] = account_id
|
||||
@@ -387,8 +386,7 @@ async def user_verify_password(
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if account_id := redis_lookup_id_random(record_id_random=x_account_id, table_name='account'): pass
|
||||
else: return mk_resp(data=False, status_code=404, response=commons.response) # Not Found
|
||||
account_id = commons.x_account_id
|
||||
|
||||
if password := user_obj.password: pass
|
||||
else: return mk_resp(data=False, status_code=400, status_message='The password to verify is required.', response=commons.response) # Bad Request
|
||||
@@ -616,8 +614,8 @@ async def lookup_user_obj(
|
||||
# Look up a user with an email address for an account
|
||||
@router.get('/user/lookup_email', response_model=Resp_Body_Base)
|
||||
async def lookup_email(
|
||||
account_id: Union[int,str],
|
||||
email: str = Query(..., min_length=2, max_length=50),
|
||||
null_account_id: bool = False,
|
||||
inc_user_role_list: bool = False,
|
||||
inc_contact: bool = False,
|
||||
inc_organization: bool = False,
|
||||
@@ -627,12 +625,7 @@ async def lookup_email(
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if account_id == '':
|
||||
account_id = None
|
||||
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, response=commons.response) # Not Found
|
||||
account_id = commons.x_account_id
|
||||
|
||||
data = {}
|
||||
data['account_id'] = account_id
|
||||
@@ -655,7 +648,7 @@ async def lookup_email(
|
||||
|
||||
log.debug(data)
|
||||
|
||||
if account_id:
|
||||
if not null_account_id:
|
||||
sql = f"""
|
||||
SELECT id AS 'user_id', id_random AS 'user_id_random'
|
||||
FROM `user` AS `user`
|
||||
@@ -711,8 +704,8 @@ async def lookup_email(
|
||||
# Look up a user with a username for an account
|
||||
@router.get('/user/lookup_username', response_model=Resp_Body_Base)
|
||||
async def lookup_username(
|
||||
account_id: Union[int,str],
|
||||
username: str = Query(..., min_length=2, max_length=50),
|
||||
null_account_id: bool = False,
|
||||
inc_address: bool = False,
|
||||
inc_contact: bool = False,
|
||||
inc_organization: bool = False,
|
||||
@@ -723,19 +716,14 @@ async def lookup_username(
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if account_id == '':
|
||||
account_id = None
|
||||
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, response=commons.response) # Not Found
|
||||
account_id = commons.x_account_id
|
||||
|
||||
data = {}
|
||||
data['account_id'] = account_id
|
||||
data['username'] = username
|
||||
log.debug(data)
|
||||
|
||||
if account_id:
|
||||
if not null_account_id:
|
||||
sql = f"""
|
||||
SELECT id AS 'user_id', id_random AS 'user_id_random'
|
||||
FROM `user` AS `user`
|
||||
@@ -794,8 +782,7 @@ async def email_auth_key_url(
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if account_id := redis_lookup_id_random(record_id_random=x_account_id, table_name='account'): pass
|
||||
else: return mk_resp(data=False, status_code=404, response=commons.response) # Not Found
|
||||
account_id = commons.x_account_id
|
||||
|
||||
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, response=commons.response) # Not Found
|
||||
|
||||
Reference in New Issue
Block a user