Skip to content

Commit

Permalink
always use password override even if already set
Browse files Browse the repository at this point in the history
will always use the override password first, then check if one is already set, then generate a default one if neither of those are true.
  • Loading branch information
tchey290 authored Oct 28, 2024
1 parent f404541 commit 7501139
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions hw_diag/utilities/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ def write_password(password):

def read_password():
PASSWORD_OVERRIDE = os.getenv('PASSWORD_OVERRIDE', 'false')
try:
password_row = g.db.query(AuthKeyValue). \
if PASSWORD_OVERRIDE != "false": # nosec
default_password = PASSWORD_OVERRIDE
password_row = write_password(default_password)
logging.info("Using password from override env var!")
else:
try:
password_row = g.db.query(AuthKeyValue). \
filter(AuthKeyValue.key == 'password_hash'). \
one()
except NoResultFound:
if PASSWORD_OVERRIDE != "false": # nosec
default_password = PASSWORD_OVERRIDE
logging.info("Using password from override env var!")
else:
except NoResultFound:
default_password = generate_default_password()
password_row = write_password(default_password)
logging.info("No password override. Generating default!")

password_row = write_password(default_password)
return password_row


Expand Down

0 comments on commit 7501139

Please sign in to comment.