From 105caf070ad3c46d51f8f375ad74115515372f05 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Mon, 23 Sep 2024 12:55:09 +0300 Subject: Add method to clear redirect url from session. --- gn2/wqflask/oauth2/session.py | 7 +++++++ gn2/wqflask/oauth2/toplevel.py | 1 + 2 files changed, 8 insertions(+) (limited to 'gn2') diff --git a/gn2/wqflask/oauth2/session.py b/gn2/wqflask/oauth2/session.py index 78c766a8..883a3228 100644 --- a/gn2/wqflask/oauth2/session.py +++ b/gn2/wqflask/oauth2/session.py @@ -98,6 +98,7 @@ def set_masquerading(masq_info): "masquerading": orig_user }) + def unset_masquerading(): """Restore the original session.""" the_session = session_info() @@ -120,9 +121,15 @@ def is_token_refreshing(): """Returns whether the token is being refreshed or not.""" return session_info().get("token_refreshing", False) + def set_redirect_url(url): """Save the current endpoint object""" return save_session_info({ **session_info(), "redirect_url": url }) + + +def clear_redirect_url(): + """Clear the redirect url from Session""" + session_info().pop("redirect_url", None) diff --git a/gn2/wqflask/oauth2/toplevel.py b/gn2/wqflask/oauth2/toplevel.py index 425c598e..8dd57243 100644 --- a/gn2/wqflask/oauth2/toplevel.py +++ b/gn2/wqflask/oauth2/toplevel.py @@ -82,6 +82,7 @@ def authorisation_code(): "logged_in": True }) redirect_url = session.session_info().get("redirect_url", "/") + session.clear_redirect_url() return redirect(redirect_url) return no_token_post("auth/token", json=request_data).either( -- cgit v1.2.3