This commit is contained in:
Scott Idem
2021-12-30 18:44:19 -05:00
parent 0866fbbed6
commit 2b809e0f81
3 changed files with 20 additions and 2 deletions

View File

@@ -230,6 +230,7 @@ async def user_authenticate(
username: Optional[str] = Query(None, min_length=3, max_length=50),
password: Optional[str] = Query(None, min_length=8, max_length=100),
auth_key: Optional[str] = Query(None, min_length=11, max_length=22),
valid_email: Optional[bool] = None,
x_account_id: str = Header(...),
inc_user_role_list: bool = False,
inc_contact: bool = False,
@@ -301,6 +302,8 @@ async def user_authenticate(
update_user_data = {}
update_user_data['id'] = user_rec_result.get('user_id', None) # Using ID, not ID Random
update_user_data['auth_key'] = None
if valid_email:
update_user_data['email_verified'] = True
if user_rec_update_result := sql_update(table_name='user', data=update_user_data):
log.info(f'The user record was updated with a NULL auth_key. User ID: {user_id}')
@@ -356,6 +359,19 @@ async def user_authenticate(
else:
log.warning('The enable_to datetime was not set. Ignoring this check.')
update_user_data = {}
update_user_data['id'] = user_rec_result.get('user_id', None) # Using ID, not ID Random
if valid_email:
update_user_data['email_verified'] = True
update_user_data['logged_in_on'] = datetime.datetime.utcnow()
if user_rec_update_result := sql_update(table_name='user', data=update_user_data):
log.info(f'The user record was updated with a NULL auth_key. User ID: {user_id}')
else:
log.error(f'The user record was not updated with a NULL auth_key. User ID: {user_id}')
log.debug(update_user_data)
log.debug(user_rec_update_result)
# Try to load the user object
if user_obj_result := load_user_obj(
user_id = user_id,