Update server.py

pull/255/head
Keyvan Hardani 9 months ago committed by GitHub
parent c059cf1f94
commit 4d66490f02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -147,15 +147,8 @@ async def authenticate(websocket: WebSocket):
# Verify the provided token # Verify the provided token
token = auth_response.get("token") token = auth_response.get("token")
if not token: expected_token = os.getenv("WS_TOKEN")
await websocket.send_json({"type": "auth_failure"}) if token != expected_token:
await websocket.close()
return False
try:
# Use the OAuth2PasswordBearer scheme to validate the token
token = await oauth2_scheme(token)
except Exception:
await websocket.send_json({"type": "auth_failure"}) await websocket.send_json({"type": "auth_failure"})
await websocket.close() await websocket.close()
return False return False

Loading…
Cancel
Save