General clean up. Sort of bug fix for create_user_obj method with new passwords.
This commit is contained in:
@@ -29,6 +29,7 @@ def create_user_obj(
|
||||
person_id: int = None, # This should be required in the future
|
||||
allow_update: bool = False, # Allow updating the user account if one is found
|
||||
avoid_dup_username: bool = False, # Avoid creating a duplicate by modifying the supplied username
|
||||
set_default_password: bool = True,
|
||||
create_sub_obj: bool = False,
|
||||
fail_any: bool = True, # Fail if any thing goes wrong for sub objects
|
||||
return_dict: bool = False,
|
||||
@@ -70,12 +71,17 @@ def create_user_obj(
|
||||
user_dict['account_id'] = account_id
|
||||
|
||||
if user_obj.new_password:
|
||||
log.warning('A new password was passed.')
|
||||
log.debug(user_obj.new_password)
|
||||
else:
|
||||
elif set_default_password:
|
||||
log.warning('A new password was not passed. Setting a default password.')
|
||||
user_obj.new_password = secrets.token_urlsafe(default_num_bytes)
|
||||
hash_string = secure_hash_string(string=user_obj.new_password)
|
||||
user_obj.password = hash_string
|
||||
user_dict['password'] = hash_string
|
||||
else:
|
||||
log.warning('A new password was not passed and not setting a default password.')
|
||||
|
||||
|
||||
log.debug(user_obj.new_password)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user