Allow overriding view authentication system

This commit is contained in:
Ales (Shagi) Zabala Alava 2022-08-03 09:11:36 +02:00
parent a97004ddc7
commit 40946be0e6
1 changed files with 5 additions and 2 deletions

View File

@ -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)