Skip to content
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

fix(auth): ensure PigeonAuthCredential is passed back to Dart side within try/catch #11683

Merged
merged 3 commits into from
Oct 12, 2023

Conversation

russellwheatley
Copy link
Member

@russellwheatley russellwheatley commented Oct 10, 2023

Description

Whilst testing this code, I observed a few issues:

TwitterAuthProvider twitterProvider =
    TwitterAuthProvider();
try {
  await FirebaseAuth.instance.currentUser!
      .linkWithProvider(twitterProvider);
} on FirebaseAuthException catch (e) {
  if (e.code == 'credential-already-in-use') {
    print(
        'The account already exists for that email. - ${e.credential}');
    await FirebaseAuth.instance.signOut();
    final cred = await FirebaseAuth.instance
        .signInWithCredential(e.credential!);
  }
}
  1. We were not passing back the AuthCredential when present on the exception which was an issue for both andriod and iOS. Fixed here.
  2. We were passing back a dictionary of AuthCredential on iOS side, we needed to pass back the PigeonAuthCredential. Fixed here.
  3. We were passing a generic "sign-in-failed" exception and not using the code from the error. Fixed here.
  4. Upon using signInWithCredential after linkWithProvider failed with this exception code credential-already-in-use, we were receiving an exception code for signInWithCredential that was network error code (i.e. the number "400"), I have updated to check if the error code is a number and responded with the underlying error code. Fixed here.

Related Issues

fixes #11164
fixes #11686

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.
  • 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.

@russellwheatley russellwheatley changed the title fix(auth, apple): ensure PigeonAuthCredential is passed back to Dart side fix(auth): ensure PigeonAuthCredential is passed back to Dart side Oct 10, 2023
@russellwheatley russellwheatley changed the title fix(auth): ensure PigeonAuthCredential is passed back to Dart side fix(auth): ensure PigeonAuthCredential is passed back to Dart side within try/catch Oct 10, 2023
@russellwheatley russellwheatley merged commit d42c339 into master Oct 12, 2023
30 checks passed
@russellwheatley russellwheatley deleted the auth-11164 branch October 12, 2023 13:04
@suysoftware
Copy link

/Users/suy/.pub-cache/hosted/pub.dev/firebase_auth-4.11.0/macos/Classes/PigeonParser.m:5:9: fatal error: 'PigeonParser.h' file not found
#import "PigeonParser.h"
^~~~~~~~~~~~~~~~

@sunmeetsingh2606
Copy link

/Users/suy/.pub-cache/hosted/pub.dev/firebase_auth-4.11.0/macos/Classes/PigeonParser.m:5:9: fatal error: 'PigeonParser.h' file not found #import "PigeonParser.h" ^~~~~~~~~~~~~~~~

Facing same issue with the latest version of firebase_auth (4.11.0)

LocLt-Mobile pushed a commit to guide-inc-org/guide-flutter_fire that referenced this pull request Oct 29, 2023
@firebase firebase locked and limited conversation to collaborators Nov 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants