Break a redirection loop in teamkfet_required

This commit is contained in:
Martin Pépin 2020-09-17 21:36:17 +02:00
parent a98e56d316
commit 7b8d1575c0
No known key found for this signature in database
GPG key ID: E7520278B1774448

View file

@ -1,8 +1,15 @@
from django.contrib.auth.decorators import user_passes_test
from django.core.exceptions import PermissionDenied
def kfet_is_team(user):
return user.has_perm("kfet.is_team")
if user.is_authenticated:
if user.has_perm("kfet.is_team"):
return True
else:
raise PermissionDenied
else:
return False
teamkfet_required = user_passes_test(kfet_is_team)