Skip to content

Conversation

appflowy
Copy link
Contributor

@appflowy appflowy commented Apr 8, 2025

Enhancements:

  • Remove local authentication type
  • Simplify authentication flow
  • Improve user onboarding experience

Chores:

  • Refactor authentication-related code
  • Update default user naming

Summary by Sourcery

Implement anonymous mode for AppFlowy, allowing users to use the application without creating an account

New Features:

  • Add support for anonymous user mode with isolated data storage

Enhancements:

  • Remove local authentication type
  • Simplify authentication flow
  • Improve user onboarding experience

Chores:

  • Refactor authentication-related code
  • Update default user naming

Copy link
Contributor

sourcery-ai bot commented Apr 8, 2025

Reviewer's Guide by Sourcery

This pull request implements anonymous mode, allowing users to use the application without creating an account. It includes changes to authentication flow, data storage, and user onboarding. The local authentication type was removed, and the default user naming was updated.

Sequence diagram for signing up as guest

sequenceDiagram
    participant FE as Frontend
    participant AuthService
    participant UserEventSignUp
    participant UserProfilePB

    FE->>AuthService: signUpAsGuest()
    activate AuthService
    AuthService->>UserEventSignUp: Send SignUpPayloadPB
    activate UserEventSignUp
    UserEventSignUp-->>AuthService: FlowyResult<UserProfilePB, FlowyError>
    deactivate UserEventSignUp
    AuthService-->>FE: FlowyResult<UserProfilePB, FlowyError>
    deactivate AuthService
Loading

Updated class diagram for AppFlowyCoreConfig

classDiagram
    class AppFlowyCoreConfig {
        +String application_path
        +String device_id
        +String platform
        +String log_filter
        +AFCloudConfiguration cloud_config
        +bool is_anon
    }

    note for AppFlowyCoreConfig "Added is_anon field to indicate anonymous mode"
Loading

Updated class diagram for AuthService

classDiagram
    class AuthService {
        <<interface>>
        +Future~FlowyResult~UserProfilePB, FlowyError~~ signUpAsGuest(Map~String, String~ params)
    }

    note for AuthService "signUpAsGuest now returns Future<void>"
Loading

File-Level Changes

Change Details Files
Implements anonymous mode for AppFlowy, allowing users to use the application without creating an account.
  • Adds support for anonymous user mode with isolated data storage.
  • Removes local authentication type.
  • Simplifies authentication flow.
  • Improves user onboarding experience.
  • Refactors authentication-related code.
  • Updates default user naming.
frontend/appflowy_flutter/lib/user/application/auth/backend_auth_service.dart
frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/settings_account_view.dart
frontend/appflowy_flutter/lib/startup/tasks/rust_sdk.dart
frontend/rust-lib/flowy-user/src/user_manager/manager.rs
frontend/appflowy_flutter/lib/env/cloud_env.dart
frontend/appflowy_flutter/lib/user/presentation/screens/splash_screen.dart
frontend/rust-lib/flowy-core/src/lib.rs
frontend/rust-lib/flowy-user/src/user_manager/manager_history_user.rs
frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/account/account_sign_in_out.dart
frontend/appflowy_flutter/lib/user/application/sign_in_bloc.dart
frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/mobile_sign_in_screen.dart
frontend/rust-lib/flowy-core/src/config.rs
frontend/appflowy_flutter/lib/user/presentation/screens/skip_log_in_screen.dart
frontend/appflowy_flutter/lib/startup/deps_resolver.dart
frontend/appflowy_flutter/integration_test/shared/base.dart
frontend/appflowy_flutter/lib/startup/startup.dart
frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/sign_in_agreement.dart
frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/setting_cloud.dart
frontend/appflowy_flutter/lib/user/application/auth/af_cloud_auth_service.dart
frontend/appflowy_flutter/lib/user/application/auth/af_cloud_mock_auth_service.dart
frontend/rust-lib/flowy-user-pub/src/lib.rs
frontend/appflowy_flutter/lib/env/backend_env.dart
frontend/appflowy_flutter/lib/user/application/auth/auth_service.dart
frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/setting_local_cloud.dart
frontend/rust-lib/dart-ffi/src/lib.rs
frontend/rust-lib/flowy-user/src/event_handler.rs
frontend/rust-lib/dart-ffi/src/env_serde.rs
frontend/appflowy_flutter/ios/Podfile.lock
frontend/appflowy_flutter/macos/Podfile.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@appflowy appflowy marked this pull request as ready for review April 13, 2025 04:16
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @appflowy - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a clear way to exit anonymous mode and transition to a registered account.
  • Ensure the anonymous mode data is properly cleared when a user signs out or transitions to a full account.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

System::long_os_version(),
platform
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (complexity): Consider extracting the anonymous user logic into a dedicated helper method to simplify the conditional logic and reduce nesting depth, improving code clarity and maintainability

Consider extracting the anonymous user logic into a dedicated helper method to flatten the nested conditionals and reduce the temporary variables. For example:

async fn process_anon_user(&self, create: bool) -> FlowyResult<()> {
    if create {
        self.user_manager.create_anon_user_once().await
    } else {
        self.user_manager.active_anon_user().await
    }
}

Then update your initialization block as follows:

let is_anon = config.is_anon;
let create_anon = is_anon && !Path::new(&config.storage_path).exists();
let this = Self::init(config, runtime).await;
if is_anon {
    if let Err(err) = this.process_anon_user(create_anon).await {
        error!("Anon user process failed: {}", err);
    }
}

This refactoring isolates the anonymous user logic and reduces nested ifs while preserving all functionality.

@appflowy appflowy changed the title chore: anon mode [WIP] chore: anon mode Apr 13, 2025
Copy link

🥷 Ninja i18n – 🛎️ Translations need to be updated

Project /project.inlang

lint rule new reports level link
Missing translation 29 warning contribute (via Fink 🐦)

@appflowy appflowy changed the title [WIP] chore: anon mode [WIP] chore:vault mode Apr 15, 2025
@appflowy appflowy changed the title [WIP] chore:vault mode [WIP]feat: vault mode Apr 15, 2025
@appflowy appflowy marked this pull request as draft May 1, 2025 03:08
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