Skip to content

Conversation

@Miduo666
Copy link

@Miduo666 Miduo666 commented Dec 12, 2025

Pull Request Details

What issue does this PR address

  • See Below

Associated Issue

  • Is there a related issue #

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

What testing has been done?

Checklist

Complete the check-list below to ensure your branch is ready for PR.

  • Screenshots included in linked issue #
  • Changes adhere to the style and coding guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • Any dependent changes have been merged and published in downstream modules
  • The update contains no confidential information
  • The update has no duplicated content
  • No lint check errors are related to these changes (make prep or flutter analyze lib)
  • Integration test dart test output or screenshot included in issue #
  • I tested the PR on these devices:
    • Android
    • iOS
    • Linux
    • MacOS
    • Windows
    • Web
  • I have identified reviewers
  • The PR has been approved by reviewers

Finalising

Once PR discussion is complete and reviewers have approved:

  • Merge dev into the this branch
  • Resolve any conflicts
  • Add a one line summary into the CHANGELOG.md
  • Push to the git repository and review
  • Merge the PR into dev

@Miduo666
Copy link
Author

Summary

This PR fixes authentication reliability issues and enables Flutter Web support by implementing reactive state management, robust error handling, and platform-safe storage operations.

Key Changes

1. Reactive Auth State (authStateNotifier)

  • Implemented ValueNotifier for real-time UI updates on login/logout.
  • Replaced inefficient polling with event-driven state listening.

2. Robust Authentication Flow (authenticate.dart & authdata_manager.dart)

  • Validation: Added checks for accessToken and webId before saving auth data to prevent crashes.
  • Smart Extraction: Now extracts webId from both accessToken and idToken to support various OAuth providers.
  • Sync Access: Added isLoggedInSync() and getCachedWebId() for instant, synchronous status checks.
  • Logout Safety: Introduced _wasExplicitlyDeleted flag to prevent accidental data reloading after logout.

3. Web Support & Platform Safety

  • Fixed Web Crashes: Replaced dart:io file operations with FlutterSecureStorage in key_manager.dart, ensuring compatibility across Web, Android, and iOS.
  • Universal IO: Updated large_file_helper.dart to use universal_io.
  • Platform Detection: Added kIsWeb check in is_phone.dart.

4. Code Quality

  • Removed Assertions: Replaced assert() with proper exceptions in rest_api.dart and others to prevent silent failures in release builds.
  • Memory Cleanup: Guaranteed in-memory state clearing during logout even if storage deletion fails.

Copy link
Contributor

@gjwgit gjwgit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup

@Miduo666
Copy link
Author

Miduo666 commented Dec 27, 2025

The total count of remaining TODOs down to 4 @gjwgit

@Miduo666
Copy link
Author

Miduo666 commented Dec 27, 2025

All existing code continues to work without modification. The new structures are optional improvements for avoiding name conflicts.

Please review and let me know if you'd like me to update any imports to reference these new files.

Thanks!

@cdawei cdawei mentioned this pull request Jan 8, 2026
28 tasks
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.

2 participants