From a2332b78cdc5876ed816e80c2a9261b90f2e9c8c Mon Sep 17 00:00:00 2001 From: virusdefender Date: Sat, 30 Jun 2018 14:40:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=94=E8=B5=9B=E7=9B=B8=E5=85=B3api?= =?UTF-8?q?=E9=83=BD=E9=9C=80=E8=A6=81=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- account/decorators.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/account/decorators.py b/account/decorators.py index 92f2908..7d89657 100644 --- a/account/decorators.py +++ b/account/decorators.py @@ -79,14 +79,15 @@ def check_contest_permission(check_type="details"): except Contest.DoesNotExist: return self.error("Contest %s doesn't exist" % contest_id) + # Anonymous + if not user.is_authenticated(): + return self.error("Please login first.") + # creator or owner - if user.is_authenticated() and user.is_contest_admin(self.contest): + if user.is_contest_admin(self.contest): return func(*args, **kwargs) if self.contest.contest_type == ContestType.PASSWORD_PROTECTED_CONTEST: - # Anonymous - if not user.is_authenticated(): - return self.error("Please login first.") # password error if self.contest.id not in request.session.get("accessible_contests", []): return self.error("Password is required.")