Skip to content

Commit

Permalink
Update auth.py
Browse files Browse the repository at this point in the history
  • Loading branch information
shawaj authored Oct 16, 2024
1 parent 01f2208 commit f68a06a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion hw_diag/utilities/auth.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import datetime
import bcrypt

Expand Down Expand Up @@ -68,12 +69,19 @@ def write_password(password):


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

password_row = write_password(default_password)
return password_row

Expand Down

0 comments on commit f68a06a

Please sign in to comment.