Skip to content

Fixed multiple accounts login#29

Open
defnax wants to merge 1 commit into
masterfrom
fix-multiple-accounts-login
Open

Fixed multiple accounts login#29
defnax wants to merge 1 commit into
masterfrom
fix-multiple-accounts-login

Conversation

@defnax

@defnax defnax commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

I have fixed the issue preventing login with a second account and resolved the associated Flutter crash.
What was wrong:

  1. Authentication Credential Mismatch: When creating a second account, the RetroShare JSON API sometimes expects the pgpName or the specific locationId as the login username, rather than the locationName. The previous code was not flexible enough to handle these different cases.

  2. Core Initialization Latency: After unlocking an account (logging in), the RetroShare core engine sometimes takes 1–3 seconds to fully initialize the JSON API for that specific account. Checking for a valid authentication token instantly would often return a false failure.

  3. UI Navigation Crash: The FlareActor#... DISPOSED error was caused by a conflict in the widget tree. When a login failed, the app tried to show an error dialog while the "Loading" splash screen was still active and transitioning, leading to a disposal race condition.
    Fixes applied:

  4. Multi-Username Fallback: Updated lib/provider/auth.dart to automatically try multiple username candidates (locationId, pgpName, and locationName) when initializing the authentication token. This ensures the app can log into accounts regardless of how they were created.

  5. Auth Retry Loop: Added a small retry loop (up to 3 attempts with 1-second delays) for the authentication token validation. This gives the core engine enough time to "wake up" the JSON API after an account is unlocked.

  6. Safe Navigation: Refactored SignInScreen and SignUpScreen to explicitly close the loading screen before showing any error dialogs. This prevents the Flare animation library from crashing during route changes.

  7. Simplified Dialogs: Cleaned up the dialog logic in lib/common/show_dialog.dart to ensure consistent and stable behavior across the app.
    The second account login should now work reliably without errors or crashes.

// Updated auth check logic in lib/provider/auth.dart: for (int retry = 0; retry < 3; retry++) { if (success = await RsJsonApi.isAuthTokenValid(...)) return true; await Future.delayed(Duration(seconds: 1)); }

code by gemini

@defnax defnax mentioned this pull request Jun 25, 2026
@defnax defnax force-pushed the fix-multiple-accounts-login branch from 5ecb3d8 to cc9e852 Compare June 29, 2026 21:39
@defnax defnax force-pushed the fix-multiple-accounts-login branch from cc9e852 to 88e307a Compare June 30, 2026 19:44
@defnax defnax mentioned this pull request Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant