diff --git a/.claude/worktrees/agent-ac72c5f4 b/.claude/worktrees/agent-ac72c5f4 new file mode 160000 index 0000000..c756b9c --- /dev/null +++ b/.claude/worktrees/agent-ac72c5f4 @@ -0,0 +1 @@ +Subproject commit c756b9cffa5a357b6d35af523562b02ec6948760 diff --git a/Client/origin-client/autoloads/Auth.gd b/Client/origin-client/autoloads/Auth.gd index dcd328e..2e91986 100644 --- a/Client/origin-client/autoloads/Auth.gd +++ b/Client/origin-client/autoloads/Auth.gd @@ -79,9 +79,13 @@ func login_with_keycloak(access_token: String, refresh_token: String) -> void: keycloak_refresh_token = refresh_token _save_session() _pending_keycloak_token = access_token - if Network.is_online(): - _send_keycloak_auth() - # else: _on_network_connected will send it once the socket connects. + # Always force a fresh WebSocket connection so auth.keycloak is the very + # first message the server sees. The socket that was open while the user + # was in the browser has likely already been closed by the server's + # AuthTimeoutMs (10 s of silence) — sending on that stale connection + # yields no reply. force_reconnect() closes it immediately; the next + # _on_network_connected() will call _send_keycloak_auth(). + Network.force_reconnect() ## Clear all auth state and disconnect, returning to the login screen. @@ -146,6 +150,11 @@ func _send_keycloak_auth() -> void: { "keycloakToken": token }, func(_type: String, p: Variant): _on_auth_ok(p), func(code: String, msg: String): + if code == "DISCONNECTED": + # Transient drop — keep the refresh token and surface the error. + # _on_network_connected will retry auth.keycloak on the next reconnect. + auth_failed.emit(code, msg) + return # Keycloak token rejected (invalid, expired, missing role). keycloak_refresh_token = "" _save_session() diff --git a/Client/origin-client/autoloads/Keycloak.gd b/Client/origin-client/autoloads/Keycloak.gd index 4882ae2..fb3bd1c 100644 --- a/Client/origin-client/autoloads/Keycloak.gd +++ b/Client/origin-client/autoloads/Keycloak.gd @@ -243,7 +243,7 @@ func _exchange_code(code: String) -> void: func _on_exchange_completed( _result: int, status: int, _headers: PackedStringArray, body: PackedByteArray) -> void: - var json := JSON.parse_string(body.get_string_from_utf8()) + var json : Variant = JSON.parse_string(body.get_string_from_utf8()) if status != 200 or json == null or not (json is Dictionary): auth_error.emit("Token exchange failed (HTTP %d)." % status) return @@ -257,7 +257,7 @@ func _on_exchange_completed( func _on_refresh_completed( _result: int, status: int, _headers: PackedStringArray, body: PackedByteArray) -> void: - var json := JSON.parse_string(body.get_string_from_utf8()) + var json :Variant= JSON.parse_string(body.get_string_from_utf8()) if status != 200 or json == null or not (json is Dictionary): auth_error.emit("Token refresh failed (HTTP %d)." % status) return diff --git a/Client/origin-client/autoloads/Keycloak.gd.uid b/Client/origin-client/autoloads/Keycloak.gd.uid new file mode 100644 index 0000000..ea94c4d --- /dev/null +++ b/Client/origin-client/autoloads/Keycloak.gd.uid @@ -0,0 +1 @@ +uid://bqnvbrk2p83g1