Reject unauthenticated users + exponential wait time
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
parent
ea264fbca6
commit
7ae015cef9
|
@ -51,6 +51,7 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||||
# User is not authenticated
|
# User is not authenticated
|
||||||
await self.close()
|
await self.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
reg = await Registration.objects.aget(user_id=user.id)
|
reg = await Registration.objects.aget(user_id=user.id)
|
||||||
self.registration = reg
|
self.registration = reg
|
||||||
|
|
||||||
|
@ -75,6 +76,10 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||||
Called when the websocket got disconnected, for any reason.
|
Called when the websocket got disconnected, for any reason.
|
||||||
:param close_code: The error code.
|
:param close_code: The error code.
|
||||||
"""
|
"""
|
||||||
|
if self.scope['user'].is_anonymous:
|
||||||
|
# User is not authenticated
|
||||||
|
return
|
||||||
|
|
||||||
# Unregister from channel layers
|
# Unregister from channel layers
|
||||||
if not self.registration.is_volunteer:
|
if not self.registration.is_volunteer:
|
||||||
await self.channel_layer.group_discard(f"team-{self.registration.team.trigram}", self.channel_name)
|
await self.channel_layer.group_discard(f"team-{self.registration.team.trigram}", self.channel_name)
|
||||||
|
|
Loading…
Reference in New Issue