From e16d7750c9f1e754a3e14a496380de0b014fffe1 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 29 Jul 2024 16:04:13 -0500 Subject: Provide a generalised way to handle errors and exceptions. --- uploader/oauth2/views.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'uploader/oauth2') 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())) -- cgit v1.2.3