Skip to content

Commit

Permalink
fix(ui_oauth_apple): fix AuthAction.link for Apple Sign In (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
lesnitsky committed Nov 5, 2023
1 parent c1f9ef6 commit b69c8ed
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions packages/firebase_ui_oauth_apple/lib/src/provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,18 @@ class AppleProvider extends OAuthProvider {
void mobileSignIn(AuthAction action) {
authListener.onBeforeSignIn();
auth.signInWithProvider(firebaseAuthProvider).then((userCred) {
if (action == AuthAction.signIn) {
authListener.onSignedIn(userCred);
} else {
authListener.onCredentialLinked(userCred.credential!);
}
}).catchError((err) {
authListener.onError(err);
});
if (action == AuthAction.link) {
auth.currentUser
?.linkWithProvider(firebaseAuthProvider)
.then(_onLinked)
.catchError(authListener.onError);
return;
}
auth
.signInWithProvider(firebaseAuthProvider)
.then(authListener.onSignedIn)
.catchError(authListener.onError);
}
@override
Expand Down Expand Up @@ -92,4 +95,8 @@ class AppleProvider extends OAuthProvider {
platform == TargetPlatform.iOS ||
platform == TargetPlatform.macOS;
}
void _onLinked(fba.UserCredential userCredential) {
authListener.onCredentialLinked(userCredential.credential!);
}
}

0 comments on commit b69c8ed

Please sign in to comment.