diff options
author | Frederick Muriuki Muriithi | 2024-07-29 16:04:13 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-08-05 09:52:18 -0500 |
commit | e16d7750c9f1e754a3e14a496380de0b014fffe1 (patch) | |
tree | c24e12b1381cd61363febfc5bcde165bd8fd0a46 /uploader/oauth2 | |
parent | d3fd64fb5237febb9628c4ccbd259969327ab2ec (diff) | |
download | gn-uploader-e16d7750c9f1e754a3e14a496380de0b014fffe1.tar.gz |
Provide a generalised way to handle errors and exceptions.
Diffstat (limited to 'uploader/oauth2')
-rw-r--r-- | uploader/oauth2/views.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/uploader/oauth2/views.py b/uploader/oauth2/views.py index d196e22..40211c8 100644 --- a/uploader/oauth2/views.py +++ b/uploader/oauth2/views.py @@ -15,6 +15,7 @@ from flask import ( from uploader import session from uploader import monadic_requests as mrequests +from uploader.monadic_requests import make_error_handler from . import jwks from .client import ( @@ -118,12 +119,6 @@ def logout(): flash("Successfully logged out.", "alert-success") return redirect("/") - def __handle_failure__(_failure): - app.logger.debug("There was a failure logging out of the system", - exc_info=True, stack_info=True) - __unset_session__(session.session_info()) - return redirect("/") - if user_logged_in(): return session.user_token().then( lambda _tok: mrequests.post( @@ -133,5 +128,8 @@ def logout(): "client_id": oauth2_clientid(), "client_secret": oauth2_clientsecret() })).either( - __handle_failure__, + make_error_handler( + redirect_to=redirect("/"), + cleanup_thunk=lambda: __unset_session__( + session.session_info())), lambda res: __unset_session__(session.session_info())) |