From 8cac2c299e8ac6d2f217056a6ebb2785fbed7179 Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Mon, 2 Dec 2024 16:09:25 +0000 Subject: [PATCH 1/2] remove password --- src/auth.py | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/src/auth.py b/src/auth.py index 4877cec..4cbb414 100644 --- a/src/auth.py +++ b/src/auth.py @@ -35,7 +35,6 @@ def check_password(): ) auth0_logged = False - password_logged = False # check if we have logged on with a password, if we havent show auth0 if ("password_correct" not in st.session_state) or (not st.session_state["password_correct"]): @@ -61,27 +60,7 @@ def check_password(): else: auth0_logged = True - # if we have not logged in with auth0 - if not auth0_logged: - if "password_correct" not in st.session_state: - # First run, show input for password. - st.text_input( - "Password", type="password", on_change=password_entered, key="password", autocomplete="current-password" - ) - - elif not st.session_state["password_correct"]: - # Password not correct, show input + error. - st.text_input( - "Password", type="password", on_change=password_entered, key="password", autocomplete="current-password" - ) - st.error("😕 Password incorrect") - - else: - # Password correct, show success message. - st.success("🔒 Password correct") - password_logged = True - - if auth0_logged or password_logged: + if auth0_logged: return True else: st.text('Please log in') From 459eb9f735b48be800fe6666631ac336b7da0874 Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Mon, 2 Dec 2024 16:34:23 +0000 Subject: [PATCH 2/2] make check password page simplier --- src/auth.py | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/auth.py b/src/auth.py index 4cbb414..8fab8cf 100644 --- a/src/auth.py +++ b/src/auth.py @@ -36,31 +36,25 @@ def check_password(): auth0_logged = False - # check if we have logged on with a password, if we havent show auth0 - if ("password_correct" not in st.session_state) or (not st.session_state["password_correct"]): - show_auth0 = True - else: - show_auth0 = False - with col2: - if show_auth0: - # show auth0 log in - try: - user_info = login_button(clientId=clientId, domain=domain,debug_logs=True) - except Exception as e: - st.text('Could not run auth') - logger.error(f'Could not run auth {e}') - - if user_info is None: - st.text('No user info') - - if user_info: - if '@openclimatefix.' not in user_info['email']: - st.text('This is only available to OCF members') - else: - auth0_logged = True + # show auth0 log in + try: + user_info = login_button(clientId=clientId, domain=domain) + except Exception as e: + st.text('Could not run auth') + logger.error(f'Could not run auth {e}') + + if user_info is None: + st.text('No user info') + + if user_info: + if '@openclimatefix.' not in user_info['email']: + st.text('This is only available to OCF members') + else: + auth0_logged = True if auth0_logged: + st.text('Hi ' + user_info['email']) return True else: st.text('Please log in')