🐛 [UI] Forgot Password exception message persisting even after email successfully sent #8804
Labels
plugin: ui
resolution: fixed
A fix has been merged or is pending merge from a PR.
type: bug
Something isn't working
Bug report
Describe the bug
When visiting "Forgot Password", you are able to type in an email. In some cases, you will trigger a
FirebaseAuthException
and when that happens, the exception message sticks around on the next screen even though the e-mail has been sent off successfully.I have added solutions to fix this bug at the bottom of this post in the section 'Additional context'.
Steps to reproduce
1. Confirm basic textfield form validation
The email textfield has basic form validation, e.g. typing in "abc" and tapping "Reset password" will display the following textfield validation error: "Provide a valid email", thats good.
Now try the e-mail "john.doe@example", and tap on "Reset password". It will still display "Provide a valid email", so far so good.
2. Cause a FirebaseAuthException on purpose
2.1. Using non-existing Firebase Auth e-mail
Type in an e-mail that you do not have in your Firebase Auth instance, it will trigger the following Exception: "Account doesn't exist"
(Optional) 2.2. - Hardware keyboard
Optionally, you can cause another exception by typing in the e-mail "john.doe@example", select the textfield so that it is in focus, connect a hardware keyboard and hit the "Enter" key. The page will now display the following exception: "This email address is badly formatted." because we are missing ".com" (or any TLD) behind our e-mail address.
Grammar side note
The issue
The exception message does not disappear even when the e-mail is corrected and has been sent off successfully. See image below.
Expected behavior
The exception message should not appear on this page:
Sample project
No sample project provided. Please use flutterfire_ui and have it working with e-mail auth. In my case, I used e-mail & password in this example.
Additional context
The issue can be resolved different ways. The bug lies in the following file: packages/flutterfire_ui/lib/src/auth/views/forgot_password_view.dart
Solution 1. Set exception to null
On line 52, in the file
forgot_password_view.dart
, the exception gets set but never cleared. A solution would be to writeexception = null;
on line 49.Permalink:
flutterfire/packages/flutterfire_ui/lib/src/auth/views/forgot_password_view.dart
Line 49 in 982bdfb
Solution 2. Hide exception message when email has been sent
On line 87, the only condition to show the exception message is having one. We could add another condition such as
exception != null && !emailSent
.Permalink:
flutterfire/packages/flutterfire_ui/lib/src/auth/views/forgot_password_view.dart
Line 87 in 982bdfb
The text was updated successfully, but these errors were encountered: