Skip to content

Commit

Permalink
use query params
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-XT committed Jun 13, 2024
1 parent e3a1db7 commit 4fbc050
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions components/Auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ def google_sso_button():
},
)
if response.status_code == 200:
url = response.json()["detail"]
url = str(response.json()["detail"])
token = url.split("token=")[1]
st.session_state["token"] = token
st.query_params["token"] = token


def get_user():
app_name = os.environ.get("APP_NAME", "Magical Auth")
auth_uri = os.environ.get("MAGICALAUTH_SERVER", "http://localhost:12437")
email = get_cookie("email", str(time.time()))
token = get_cookie("token", str(time.time()))
email = get_cookie("email")
token = get_cookie("token")
if "mfa_confirmed" in st.session_state:
st.title(app_name)
st.success("MFA token confirmed! Please check your email for the login link.")
Expand All @@ -78,15 +78,15 @@ def get_user():
st.stop()
if "email" in st.query_params:
if st.query_params["email"] != "" and st.query_params["email"] is not None:
set_cookie("email", st.query_params["email"], 1, str(time.time()))
set_cookie("email", st.query_params["email"], 1)
email = st.query_params["email"]
if "token" in st.query_params:
if (
st.query_params["token"] != ""
and st.query_params["token"] is not None
and st.query_params["token"] != "None"
):
set_cookie("token", st.query_params["token"], 1, str(time.time()))
set_cookie("token", st.query_params["token"], 1)
token = st.query_params["token"]
if token != "" and token is not None and token != "None":
user_request = requests.get(
Expand All @@ -97,8 +97,8 @@ def get_user():
user = user_request.json()
return user
else:
set_cookie("email", "", 1, str(time.time()))
set_cookie("token", "", 1, str(time.time()))
set_cookie("email", "", 1)
set_cookie("token", "", 1)
st.title(app_name)
if "otp_uri" in st.session_state:
otp_uri = st.session_state["otp_uri"]
Expand Down

0 comments on commit 4fbc050

Please sign in to comment.