Accept active token from node
All checks were successful
release-image / release-image (push) Successful in 2m8s

This commit is contained in:
Logan Cusano
2025-06-29 02:37:17 -04:00
parent 7820e87989
commit d889f0e8ea
2 changed files with 4 additions and 2 deletions

View File

@@ -16,11 +16,12 @@ nodes_bp = Blueprint('nodes', __name__)
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."""
current_app.active_clients[client_id] = ActiveClient()
current_app.active_clients[client_id].websocket = websocket
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.")
# Create a JWT for the client

View File

@@ -42,7 +42,8 @@ async def websocket_server_handler(websocket):
if handshake_data.get("type") == "handshake" and "id" in handshake_data:
client_id = handshake_data["id"]
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:
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}))