Skip to content

disable email verification button after initial click in UserProfileForm#1151

Open
pankaj-basnet wants to merge 6 commits intowger-project:masterfrom
pankaj-basnet:fix/prevent-duplicate-verification-requests
Open

disable email verification button after initial click in UserProfileForm#1151
pankaj-basnet wants to merge 6 commits intowger-project:masterfrom
pankaj-basnet:fix/prevent-duplicate-verification-requests

Conversation

@pankaj-basnet
Copy link
Copy Markdown

@pankaj-basnet pankaj-basnet commented Mar 24, 2026

Currently, the "Verify Email" button remains active after the user clicks it. This allows for multiple simultaneous API calls if a user double-taps or clicks rapidly , leading to redundant server-side processing and multiple verification emails.

Proposed Changes

  • Introduced a boolean state _isVerifying to the UserProfileForm.

  • The OutlinedButton is now disabled (set to null) while a request is in flight.

  • Replaced the button text with a CircularProgressIndicator during the loading state to improve UX.

  • Refactored the onPressed logic to remove a redundant check for widget._profile.emailVerified, as the widget's visibility is already guarded by that condition.

  • Added if (mounted) guards to ensure setState and ScaffoldMessenger calls are only executed if the user is still on the screen.

image

Related Issue(s)

- Added `_isVerifying` state to track asynchronous verification process
- Disabled OutlinedButton during active requests to prevent duplicate API calls
- Added CircularProgressIndicator for visual feedback during loading
- Included `mounted` checks to prevent memory leaks/crashes on post-await setState
- Removed redundant verification check inside the onPressed callback
@pankaj-basnet
Copy link
Copy Markdown
Author

pankaj-basnet commented Mar 24, 2026

after disabling email verification button when clicked in UserProfileForm like above , i found we still need to either go back to previous screen or click 'save' button to go back. and, we could change the email address while at it.

- Button becomes disabled immediately after click
- Stays disabled after request succeeds
- Re-enables only if request fails
- Improve Verify button state handling in UserProfileScreen

- Disable "Verify" button after user clicks it
- Keep it disabled for the lifetime of the screen
- Re-enable on request failure
- Reset state when navigating away and back
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