diff --git a/src/aki_prj23_transparenzregister/ui/protection.py b/src/aki_prj23_transparenzregister/ui/protection.py index 5bd4509..62ab004 100644 --- a/src/aki_prj23_transparenzregister/ui/protection.py +++ b/src/aki_prj23_transparenzregister/ui/protection.py @@ -12,8 +12,13 @@ def add_auth(app: Dash) -> None: Args: app: The app a basic auth should be added to. """ - if os.getenv("PYTHON_DASH_LOGIN_USERNAME") and os.getenv("PYTHON_DASH_LOGIN_PW"): - login = os.getenv("PYTHON_DASH_LOGIN_USERNAME") - pw = os.getenv("PYTHON_DASH_LOGIN_PW") + if (login := os.getenv("PYTHON_DASH_LOGIN_USERNAME", None)) and ( + pw := os.getenv("PYTHON_DASH_LOGIN_PW", None) + ): logger.info("Staring app in password protected mode!") dash_auth.BasicAuth(app, {login: pw}) + return + logger.info("The password protection is not or only partially configured!") + logger.debug( + "The enviromental variables PYTHON_DASH_LOGIN_USERNAME and PYTHON_DASH_LOGIN_PW should be used to activate this feature." + )