Fix Keycloak: scene reload on error, web signal missed, redirect URI

PC — scene reloading on auth error:
  Auth.gd's keycloak error handler called change_scene_to_file(LoginScreen)
  after emitting auth_failed, which reloaded the scene and wiped the error
  message before the user could see it. Removed the scene change — the
  login screen is already active and handles auth_failed itself.

Web — token_received signal never handled after page redirect:
  login_screen._ready() returned early when Keycloak.auth_in_progress was
  true, before connecting Keycloak.token_received. When the exchange
  completed nobody was listening, so the game sat frozen. Signals are now
  connected before the early-return check.

Web — fragile redirect URI and sessionStorage injection:
  JavaScriptBridge.eval return value could stringify as "<null>". Now uses
  separate origin + pathname evals with a null check. sessionStorage items
  and the final navigation use uri_encode() + decodeURIComponent() instead
  of manual quote-escaping, preventing injection from PKCE values.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-04-02 19:20:04 -04:00
co-authored by Claude Happy
parent 1c6064e157
commit 79fa08e192
3 changed files with 22 additions and 10 deletions
+3 -1
View File
@@ -159,7 +159,9 @@ func _send_keycloak_auth() -> void:
keycloak_refresh_token = ""
_save_session()
auth_failed.emit(code, msg)
get_tree().change_scene_to_file("res://scenes/login/LoginScreen.tscn")
# Do NOT change scene here — the login screen is already active and
# handles auth_failed by showing the error and re-enabling the button.
# Calling change_scene_to_file would reload the screen and wipe the error.
)