Accept active token from node
All checks were successful
release-image / release-image (push) Successful in 2m8s
All checks were successful
release-image / release-image (push) Successful in 2m8s
This commit is contained in:
@@ -16,11 +16,12 @@ nodes_bp = Blueprint('nodes', __name__)
|
|||||||
pending_requests = {}
|
pending_requests = {}
|
||||||
|
|
||||||
|
|
||||||
async def register_client(websocket, client_id, client_nickname):
|
async def register_client(websocket, client_id, client_nickname, active_token):
|
||||||
"""Registers a new client connection."""
|
"""Registers a new client connection."""
|
||||||
current_app.active_clients[client_id] = ActiveClient()
|
current_app.active_clients[client_id] = ActiveClient()
|
||||||
current_app.active_clients[client_id].websocket = websocket
|
current_app.active_clients[client_id].websocket = websocket
|
||||||
current_app.active_clients[client_id].nickname = client_nickname
|
current_app.active_clients[client_id].nickname = client_nickname
|
||||||
|
current_app.active_clients[client_id].active_token = active_token
|
||||||
print(f"Client {client_id} connected.")
|
print(f"Client {client_id} connected.")
|
||||||
|
|
||||||
# Create a JWT for the client
|
# Create a JWT for the client
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ async def websocket_server_handler(websocket):
|
|||||||
if handshake_data.get("type") == "handshake" and "id" in handshake_data:
|
if handshake_data.get("type") == "handshake" and "id" in handshake_data:
|
||||||
client_id = handshake_data["id"]
|
client_id = handshake_data["id"]
|
||||||
client_nickname = handshake_data.get("nickname")
|
client_nickname = handshake_data.get("nickname")
|
||||||
await register_client(websocket, client_id, client_nickname)
|
client_active_token = handshake_data.get("active_token")
|
||||||
|
await register_client(websocket, client_id, client_nickname, client_active_token)
|
||||||
if not app.active_clients[client_id].access_token:
|
if not app.active_clients[client_id].access_token:
|
||||||
abort(500, "Error retrieving access token")
|
abort(500, "Error retrieving access token")
|
||||||
await websocket.send(json.dumps({"type": "handshake_ack", "status": "success", "access_token": app.active_clients[client_id].access_token}))
|
await websocket.send(json.dumps({"type": "handshake_ack", "status": "success", "access_token": app.active_clients[client_id].access_token}))
|
||||||
|
|||||||
Reference in New Issue
Block a user