Skip to content

Commit

Permalink
Merge pull request #2 from tchey290/patch-1
Browse files Browse the repository at this point in the history
always use password override even if already set
  • Loading branch information
tchey290 authored Oct 28, 2024
2 parents fc3eff1 + 7501139 commit 1566aec
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 1566aec

Please sign in to comment.