Fix: login screen UX + chat poll auth guard

- 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 <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-03-10 20:36:36 -04:00
co-authored by Claude Happy
parent ad06f69331
commit cb8cb59b22
2 changed files with 22 additions and 1 deletions
+2
View File
@@ -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
@@ -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."