mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-05-17 05:32:46 +00:00
Compare commits
4 Commits
758f714096
...
ec0419a6d7
Author | SHA1 | Date | |
---|---|---|---|
|
ec0419a6d7 | ||
|
54016a1fbf | ||
|
7ae015cef9 | ||
|
ea264fbca6 |
@ -47,6 +47,11 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
||||
|
||||
# Fetch the registration of the current user
|
||||
user = self.scope['user']
|
||||
if user.is_anonymous:
|
||||
# User is not authenticated
|
||||
await self.close()
|
||||
return
|
||||
|
||||
reg = await Registration.objects.aget(user_id=user.id)
|
||||
self.registration = reg
|
||||
|
||||
@ -71,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)
|
||||
|
@ -736,7 +736,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
}
|
||||
|
||||
function setupSocket() {
|
||||
function setupSocket(nextDelay = 1000) {
|
||||
// Open a global websocket
|
||||
socket = new WebSocket(
|
||||
(document.location.protocol === 'https:' ? 'wss' : 'ws') + '://' + window.location.host + '/ws/draw/'
|
||||
@ -753,7 +753,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
// Manage errors
|
||||
socket.addEventListener('close', e => {
|
||||
console.error('Chat socket closed unexpectedly, restarting…')
|
||||
setupSocket()
|
||||
setTimeout(() => setupSocket(2 * nextDelay), nextDelay)
|
||||
})
|
||||
|
||||
// When the socket is opened, set the language in order to receive alerts in the good language
|
||||
|
@ -1886,8 +1886,7 @@ class GSheetNotificationsView(View):
|
||||
return HttpResponse(status=404)
|
||||
|
||||
tournament = await Tournament.objects.prefetch_related('participations', 'pools').aget(pk=kwargs['pk'])
|
||||
request.site.domain = "test.ynerant.fr"
|
||||
expected_channel_id = sha1(f"{tournament.name}{timezone.now().date()}{request.site.domain}".encode()) \
|
||||
expected_channel_id = sha1(f"{tournament.name}-{timezone.now().date()}-{request.site.domain}".encode()) \
|
||||
.hexdigest()
|
||||
|
||||
if request.headers['X-Goog-Channel-ID'] != expected_channel_id:
|
||||
|
Loading…
x
Reference in New Issue
Block a user