Skip to content

fix(firebase_ui_auth): Avoid redundant confirmation on account deletion #494

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 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class _DeleteAccountButtonState extends State<DeleteAccountButton> {
void Function() pop<T>(BuildContext context, T result) =>
() => Navigator.of(context).pop(result);

Future<void> _deleteAccount() async {
bool? confirmed = !widget.showDeleteConfirmationDialog;
Future<void> _deleteAccount({bool skipConfirmation = false}) async {
bool? confirmed = skipConfirmation || !widget.showDeleteConfirmationDialog;

if (!confirmed) {
final l = FirebaseUILocalizations.labelsOf(context);
Expand Down Expand Up @@ -116,17 +116,16 @@ class _DeleteAccountButtonState extends State<DeleteAccountButton> {
final user = auth.currentUser!;
await auth.currentUser?.delete();

FirebaseUIAction.ofType<AccountDeletedAction>(context)?.callback(
FirebaseUIAction.ofType<AccountDeletedAction>(
context,
user,
);
)?.callback(context, user);
await FirebaseUIAuth.signOut(context: context, auth: auth);
} on fba.FirebaseAuthException catch (err) {
if (err.code == 'requires-recent-login') {
if (widget.onSignInRequired != null) {
final signedIn = await widget.onSignInRequired!();
if (signedIn) {
await _deleteAccount();
await _deleteAccount(skipConfirmation: true);
}
}
}
Expand Down