diff --git a/Client/origin-client/autoloads/Auth.gd b/Client/origin-client/autoloads/Auth.gd index 4f3e1df..cb27fba 100644 --- a/Client/origin-client/autoloads/Auth.gd +++ b/Client/origin-client/autoloads/Auth.gd @@ -101,12 +101,17 @@ func _on_network_connected() -> void: { "sessionToken": session_token }, func(_type: String, p: Variant): _on_auth_ok(p), func(code: String, msg: String): - # Keep the token on network errors — we'll retry on the next - # reconnect. Only clear it on explicit auth rejections. - if code != "DISCONNECTED": - session_token = "" - _save_session() + if code == "DISCONNECTED": + # Transient network drop — keep the token and retry on reconnect. + auth_failed.emit(code, msg) + return + # Session explicitly rejected (expired / revoked / invalid). + # Wipe all auth state, emit the failure, then drive the scene + # change here so every screen (main, collection, etc.) is covered + # without each needing its own auth_failed handler. + logout() auth_failed.emit(code, msg) + get_tree().change_scene_to_file("res://scenes/login/LoginScreen.tscn") ) diff --git a/Client/origin-client/scenes/main/main_screen.gd b/Client/origin-client/scenes/main/main_screen.gd index f416fba..db9defc 100644 --- a/Client/origin-client/scenes/main/main_screen.gd +++ b/Client/origin-client/scenes/main/main_screen.gd @@ -4,8 +4,8 @@ extends Control ## Displays the player's display name and live connection status. ## Placeholder navigation buttons for future game features. ## -## If auth.hello re-validation fails after a reconnect (expired session), -## Auth.auth_failed fires and we redirect back to the login screen. +## Session expiry is handled centrally by Auth.gd, which calls logout() and +## navigates to LoginScreen when auth.hello is rejected on reconnect. @onready var welcome_label : Label = %WelcomeLabel @onready var status_label : Label = %StatusLabel @@ -20,7 +20,6 @@ func _ready() -> void: Network.connected.connect(_update_status) Network.disconnected.connect(_update_status) - Auth.auth_failed.connect(_on_auth_failed) logout_btn.pressed.connect(_on_logout_pressed) collection_btn.pressed.connect(func(): get_tree().change_scene_to_file("res://scenes/collection/CollectionScreen.tscn")) @@ -33,8 +32,6 @@ func _exit_tree() -> void: Network.connected.disconnect(_update_status) if Network.disconnected.is_connected(_update_status): Network.disconnected.disconnect(_update_status) - if Auth.auth_failed.is_connected(_on_auth_failed): - Auth.auth_failed.disconnect(_on_auth_failed) # ── Signal handlers ─────────────────────────────────────────────────────────── @@ -47,15 +44,6 @@ func _update_status() -> void: status_label.modulate = Color(1.0, 0.8, 0.2) -func _on_auth_failed(error_code: String, _message: String) -> void: - if error_code == "DISCONNECTED": - # Transient drop during auth.hello retry — stay on screen. - # _update_status() already shows "● Reconnecting…" via the disconnected signal. - return - # Session explicitly rejected (expired, revoked, locked out) — go to login. - get_tree().change_scene_to_file("res://scenes/login/LoginScreen.tscn") - - func _on_logout_pressed() -> void: Auth.logout() get_tree().change_scene_to_file("res://scenes/login/LoginScreen.tscn")