Make sure clients are authenticated before sending messages.

As the system is asynchronous some messages could (?) slip through before the socket is closed when auth fails.
This commit is contained in:
luukas 2021-03-01 19:33:15 +02:00
parent 9c62099f32
commit 37597f920f

View File

@ -12,8 +12,9 @@ class WebSocketHelper:
self.clients.add(client)
def send_message(self, client, event_type, data):
message = str(json.dumps({'event': event_type, 'data': data}))
client.write_message(message)
if client.check_auth():
message = str(json.dumps({'event': event_type, 'data': data}))
client.write_message(message)
def broadcast(self, event_type, data):
console.debug('Sending: ' + str(json.dumps({'event': event_type, 'data': data})))