From a7d8f273dd6daa7d07ea2142596cb74c0ae3924a Mon Sep 17 00:00:00 2001 From: Johan Castiblanco Date: Tue, 19 Dec 2023 16:58:04 -0500 Subject: [PATCH] refactor: inherit from social auth exception This change the heritance of the eox-tenant-auth-exception. This with the purpose of the exception to be handled by the social tpa middleware exception process. You can see here that the new class is also based in value error exception. https://github.com/python-social-auth/social-core/blob/29cbbd22b98d81d569a886b1cc0bd9a316cd124f/social_core/exceptions.py#L1 But the change is related with this PR: https://github.com/eduNEXT/eox-core/pull/171 So now as the exception is family of the SocialAuthBaseException. The the tpa middleware could managed it. https://github.com/python-social-auth/social-app-django/blob/5.4.0/social_django/middleware.py#L35 Keep in mind that this middleware is parent of edx-platform middleware. https://github.com/openedx/edx-platform/blob/ebcbe1cd9208191c0589d7fe538c6ac13470abe6/common/djangoapps/third_party_auth/middleware.py#L18 --- eox_tenant/pipeline.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/eox_tenant/pipeline.py b/eox_tenant/pipeline.py index 6b9ec6db..385d0e30 100644 --- a/eox_tenant/pipeline.py +++ b/eox_tenant/pipeline.py @@ -2,8 +2,13 @@ The pipeline module defines functions that are used in the third party authentication flow """ +try: + from social_core.exceptions import AuthFailed +except ImportError: + AuthFailed = Exception -class EoxTenantAuthException(ValueError): + +class EoxTenantAuthException(AuthFailed): """Auth process exception.""" def __init__(self, backend, *args, **kwargs):