From 40946be0e67c412a0f484680e522841e05af2513 Mon Sep 17 00:00:00 2001 From: shagi Date: Wed, 3 Aug 2022 09:11:36 +0200 Subject: [PATCH] Allow overriding view authentication system --- gas/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gas/views.py b/gas/views.py index 19f6721..938bf7b 100644 --- a/gas/views.py +++ b/gas/views.py @@ -83,7 +83,7 @@ class GASMixin: breadcrumbs = [] actions = None - def dispatch(self, *args, **kwargs): + def check_user_forbidden(self): user = self.request.user roles = set(self.roles) roles.add(self.base_role) @@ -93,7 +93,10 @@ class GASMixin: and user.user_roles.filter(role__in=roles).count() == 0 ) ) - if access_denied: + return access_denied + + def dispatch(self, *args, **kwargs): + if self.check_user_forbidden(): return HttpResponseRedirect(reverse('gas:login') + '?next={}'.format(self.request.path)) return super().dispatch(*args, **kwargs)