Fixed multiple accounts login#29
Open
defnax wants to merge 1 commit into
Open
Conversation
Closed
5ecb3d8 to
cc9e852
Compare
cc9e852 to
88e307a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have fixed the issue preventing login with a second account and resolved the associated Flutter crash.
What was wrong:
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.
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.
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:
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.
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.
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.
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