Skip to content

fix(ui_auth): Fix EmailVerificationController lifecycle #462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

karelklic
Copy link

Description

Fix EmailVerificationController lifecycle.

Before the change, each visit to EmailVerificationScreen creates a new controller that is kept indefinitely in the background and updated on the app resume. Since EmailVerificationController assumes that a user is logged in, these controller instances throw an exception when user logs out and app resume event is called.

After this change, a EmailVerificationController is disposed when no longer needed by a screen that created it. If controller's sendVerificationEmail async method is still running during dispose, it is terminated early.

Related Issues

Fixes #9

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • All unit tests pass (melos run test:unit:all doesn't fail).
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

Before this change, EmailVerificationController created during email verification workflow remained active on the background. When user signed out within the same session, FurebaseAuth.currentUser become null and the controller accessed it assuming it's never null.

After the change, controller is disposed after leaving the verification screen.
…s disposed.

When EmailVerificationController is no longer needed, it's disposed.  However, sendVerificationEmail might still be running after disposal because it's async. It updates ValueNotifier's value, which throws an exception  when called after dispose.

This change prevents that by terminating sendVerificationEmail early when its result is no longer needed.
@karelklic karelklic changed the title fix(ui_auth): EmailVerificationController lifecycle fix(ui_auth): Fix EmailVerificationController lifecycle Jan 17, 2025
Copy link

Hello 👋, this PR has been opened for more than 2 months with no activity on it.

If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing!

You have 15 days until this gets closed automatically

@github-actions github-actions bot added the Stale Issue with no recent activity label Feb 14, 2025
@karelklic
Copy link
Author

The fix is still valid. We use it, and it works.

@github-actions github-actions bot added Needs Attention OP created or responded to issue and it needs attention. and removed Stale Issue with no recent activity labels Feb 15, 2025
Copy link

Hello 👋, this PR has been opened for more than 2 months with no activity on it.

If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing!

You have 15 days until this gets closed automatically

@github-actions github-actions bot added the Stale Issue with no recent activity label Mar 15, 2025
@karelklic
Copy link
Author

Even after two months, the fix is still valid. Awaiting feedback from the maintainer.

@github-actions github-actions bot removed the Stale Issue with no recent activity label Mar 16, 2025
Copy link

Hello 👋, this PR has been opened for more than 2 months with no activity on it.

If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing!

You have 15 days until this gets closed automatically

@github-actions github-actions bot added the Stale Issue with no recent activity label Apr 13, 2025
@karelklic
Copy link
Author

The fix is still valid.

@github-actions github-actions bot removed the Stale Issue with no recent activity label Apr 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Attention OP created or responded to issue and it needs attention.
Projects
None yet
1 participant