From cb8cb59b2220482cfc151cc3b65b7729b85e6f73 Mon Sep 17 00:00:00 2001 From: dingo Date: Tue, 10 Mar 2026 20:36:36 -0400 Subject: [PATCH] Fix: login screen UX + chat poll auth guard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Status label: connect Network.connected so "Connecting…" clears once the WebSocket opens (previously the label stuck forever with no session) - Remember Me: apply font_color override so the checkbox text is visible - Register errors: map ASP.NET Identity password-policy error codes (PasswordTooShort, PasswordRequiresUpper/Lower/NonAlphanumeric/Digit) to user-friendly strings; old WEAK_PASSWORD kept as alias - Chat poll: guard _on_message_poll_tick with Auth.user_id check so the timer cannot send chat.get_messages as the first message on a fresh connection when the user is not yet authenticated (caused by logout not stopping the timer, leaving it running into the next reconnect cycle) Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- Client/origin-client/autoloads/Chat.gd | 2 ++ .../scenes/login/login_screen.gd | 21 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Client/origin-client/autoloads/Chat.gd b/Client/origin-client/autoloads/Chat.gd index fb01eb7..c2b1bc0 100644 --- a/Client/origin-client/autoloads/Chat.gd +++ b/Client/origin-client/autoloads/Chat.gd @@ -341,6 +341,8 @@ func _stop_message_polling() -> void: func _on_message_poll_tick() -> void: + if Auth.user_id.is_empty(): + return if channels.is_empty(): return diff --git a/Client/origin-client/scenes/login/login_screen.gd b/Client/origin-client/scenes/login/login_screen.gd index b905d35..cca396b 100644 --- a/Client/origin-client/scenes/login/login_screen.gd +++ b/Client/origin-client/scenes/login/login_screen.gd @@ -50,6 +50,7 @@ func _ready() -> void: Auth.auth_success.connect(_on_auth_success) Auth.auth_failed.connect(_on_auth_failed) + Network.connected.connect(_on_network_connected) login_btn.pressed.connect(_on_login_pressed) register_btn.pressed.connect(_on_register_pressed) @@ -65,6 +66,9 @@ func _ready() -> void: password_input.text = creds[1] remember_me.button_pressed = true + # Make the Remember Me label visible against dark backgrounds. + remember_me.add_theme_color_override("font_color", Color(0.8, 0.8, 0.8)) + # Show connection / session-resume status on first open. if not Auth.session_token.is_empty(): _set_status("Resuming session…", false) @@ -78,6 +82,8 @@ func _exit_tree() -> void: Auth.auth_success.disconnect(_on_auth_success) if Auth.auth_failed.is_connected(_on_auth_failed): Auth.auth_failed.disconnect(_on_auth_failed) + if Network.connected.is_connected(_on_network_connected): + Network.connected.disconnect(_on_network_connected) # ── Button handlers ─────────────────────────────────────────────────────────── @@ -118,6 +124,12 @@ func _on_auth_success(_user_id: String, _display_name: String) -> void: _go_to_main() +func _on_network_connected() -> void: + # Once the socket is up with no session in flight, clear the spinner. + if Auth.session_token.is_empty() and status_label.text == "Connecting…": + _set_status("", false) + + func _on_auth_failed(error_code: String, message: String) -> void: _was_manual_login = false if error_code == "DISCONNECTED": @@ -152,7 +164,14 @@ func _friendly_error(code: String, message: String) -> String: "USER_NOT_FOUND": return "Wrong email or password." "EMAIL_TAKEN": return "That email is already in use." "DISPLAY_NAME_TAKEN": return "That display name is already in use." - "WEAK_PASSWORD": return "Password must be at least 8 characters." + # ASP.NET Identity password-policy codes: + "WEAK_PASSWORD", \ + "PasswordTooShort": return "Password must be at least 12 characters." + "PasswordRequiresUpper": return "Password must include an uppercase letter." + "PasswordRequiresLower": return "Password must include a lowercase letter." + "PasswordRequiresNonAlphanumeric": return "Password must include a special character (e.g. !@#$)." + "PasswordRequiresDigit": return "Password must include a number." + "PasswordRequiresUniqueChars": return "Password must contain more unique characters." "INVALID_EMAIL": return "Please enter a valid email address." "ACCOUNT_LOCKED": return "Account locked. Please try again later." "AUTH_FAILED": return "Session expired. Please sign in again."