bug fix für Nachrichtenversand vom mobilen Client
This commit is contained in:
1 parent
c793e8b16d
commit
c477a05f03
8 files changed
+133
-32
No files matched your search
@@ -10,7 +10,7 @@ Ablauf einer Verbindung:
|
||||
"""
|
||||
import json
|
||||
|
||||
from flask import session
|
||||
from flask import session, current_app
|
||||
from cmbnet.extensions import sock
|
||||
from cmbnet.ws import broker
|
||||
from cmbnet.ws.protocol import WSMessage
|
||||
@@ -74,11 +74,24 @@ def ws(ws, tenant):
|
||||
# Code 0: Authentifizierung über den Einmal-Token.
|
||||
if msg.code == 0:
|
||||
token, session_id = _parse_auth_payload(msg.msg)
|
||||
if not session_id:
|
||||
session_id = getattr(msg, 'session_id', None)
|
||||
if not token or not broker.authenticate(
|
||||
tenant_id, account_id, token, session_id
|
||||
):
|
||||
current_app.logger.warning(
|
||||
'WebSocket-Authentifizierung fehlgeschlagen: tenant=%s account=%s',
|
||||
tenant_id, account_id
|
||||
)
|
||||
ws.close()
|
||||
break
|
||||
# Bestätigt dem Client den erfolgreichen Handshake. Erst jetzt
|
||||
# darf er gepufferte fachliche Nachrichten senden.
|
||||
broker.send_to_connection(
|
||||
tenant_id,
|
||||
account_id,
|
||||
WSMessage(sender_id=0, code=0, msg='authenticated').to_json()
|
||||
)
|
||||
continue
|
||||
|
||||
# Fachliche Nachrichten sind erst nach erfolgreicher
|
||||
|
||||
Reference in new issue
Block a user