Skip to content

Commit

Permalink
set cookie then redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-XT committed Jun 13, 2024
1 parent 2eb3540 commit aed0e2f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions components/Auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def google_sso_button():
f'<meta http-equiv="refresh" content="0;URL={new_uri}">',
unsafe_allow_html=True,
)
st.stop()
if "code" in st.query_params:
if st.query_params["code"] != "":
if isinstance(st.query_params["code"], list):
Expand All @@ -65,9 +66,15 @@ def google_sso_button():
if "detail" in res:
details = str(res["detail"])
if details.startswith("http"):
token = details.split("?token=")[1]
token = details.split("token=")[1]
set_cookie("token", token, 1, "google_sso_token")
st.rerun()
# Redirect to the login link
st.markdown(
f'<meta http-equiv="refresh" content="0;URL={details}">',
unsafe_allow_html=True,
)
time.sleep(0.5)
st.stop()
else:
st.error(details)
logging.error(f"Error with Google SSO: {details}")
Expand Down

0 comments on commit aed0e2f

Please sign in to comment.