Authenticated juries get access with the extra token access
This commit is contained in:
parent
4a7d3c5604
commit
6d01298e24
|
@ -6,6 +6,7 @@ from threading import local
|
||||||
from django.contrib.sessions.backends.db import SessionStore
|
from django.contrib.sessions.backends.db import SessionStore
|
||||||
|
|
||||||
from member.models import TFJMUser
|
from member.models import TFJMUser
|
||||||
|
from tournament.models import Pool
|
||||||
|
|
||||||
USER_ATTR_NAME = getattr(settings, 'LOCAL_USER_ATTR_NAME', '_current_user')
|
USER_ATTR_NAME = getattr(settings, 'LOCAL_USER_ATTR_NAME', '_current_user')
|
||||||
SESSION_ATTR_NAME = getattr(settings, 'LOCAL_SESSION_ATTR_NAME', '_current_session')
|
SESSION_ATTR_NAME = getattr(settings, 'LOCAL_SESSION_ATTR_NAME', '_current_session')
|
||||||
|
@ -75,6 +76,11 @@ class ExtraAccessMiddleware(object):
|
||||||
def __call__(self, request):
|
def __call__(self, request):
|
||||||
if "extra_access_token" in request.GET:
|
if "extra_access_token" in request.GET:
|
||||||
request.session["extra_access_token"] = request.GET["extra_access_token"]
|
request.session["extra_access_token"] = request.GET["extra_access_token"]
|
||||||
|
if request.user.is_authenticated:
|
||||||
|
pool = Pool.objects.filter(extra_access_token=request.GET["extra_access_token"])
|
||||||
|
if pool.exists():
|
||||||
|
pool.juries.add(request.user)
|
||||||
|
pool.save()
|
||||||
else:
|
else:
|
||||||
request.session.setdefault("extra_access_token", "")
|
request.session.setdefault("extra_access_token", "")
|
||||||
return self.get_response(request)
|
return self.get_response(request)
|
||||||
|
|
Loading…
Reference in New Issue