From 7ae015cef92a0098eaf53c7fb9d4ad6bbdcc90f3 Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Sat, 6 Apr 2024 22:28:46 +0200 Subject: [PATCH] Reject unauthenticated users + exponential wait time Signed-off-by: Emmy D'Anello --- draw/consumers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/draw/consumers.py b/draw/consumers.py index 8ac2172..c54575f 100644 --- a/draw/consumers.py +++ b/draw/consumers.py @@ -51,6 +51,7 @@ class DrawConsumer(AsyncJsonWebsocketConsumer): # User is not authenticated await self.close() return + reg = await Registration.objects.aget(user_id=user.id) self.registration = reg @@ -75,6 +76,10 @@ class DrawConsumer(AsyncJsonWebsocketConsumer): Called when the websocket got disconnected, for any reason. :param close_code: The error code. """ + if self.scope['user'].is_anonymous: + # User is not authenticated + return + # Unregister from channel layers if not self.registration.is_volunteer: await self.channel_layer.group_discard(f"team-{self.registration.team.trigram}", self.channel_name)