From 7b8d1575c006f66d4e949123c5bde765abd846e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Thu, 17 Sep 2020 21:36:17 +0200 Subject: [PATCH] Break a redirection loop in teamkfet_required --- kfet/decorators.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kfet/decorators.py b/kfet/decorators.py index 70848820..e7d383a5 100644 --- a/kfet/decorators.py +++ b/kfet/decorators.py @@ -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)