Allow to impersonate user on draw interface

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2024-04-27 09:55:33 +02:00
parent b464e7df1d
commit 46fc5f39c8
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 3 additions and 0 deletions

View File

@ -9,6 +9,7 @@ from random import randint, shuffle
from asgiref.sync import sync_to_async from asgiref.sync import sync_to_async
from channels.generic.websocket import AsyncJsonWebsocketConsumer from channels.generic.websocket import AsyncJsonWebsocketConsumer
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.utils import translation from django.utils import translation
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
@ -44,6 +45,8 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
We accept only if this is a user of a team of the associated tournament, or a volunteer We accept only if this is a user of a team of the associated tournament, or a volunteer
of the tournament. of the tournament.
""" """
if '_fake_user_id' in self.scope['session']:
self.scope['user'] = await User.objects.aget(pk=self.scope['session']['_fake_user_id'])
# Fetch the registration of the current user # Fetch the registration of the current user
user = self.scope['user'] user = self.scope['user']