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)