diff --git a/src/auth.py b/src/auth.py index 4877cec..8fab8cf 100644 --- a/src/auth.py +++ b/src/auth.py @@ -35,53 +35,26 @@ 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"]): - 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 - - # 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") - + # 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: - # Password correct, show success message. - st.success("🔒 Password correct") - password_logged = True + auth0_logged = True - if auth0_logged or password_logged: + if auth0_logged: + st.text('Hi ' + user_info['email']) return True else: st.text('Please log in')