@@ -158,10 +158,10 @@ - (void)signInWithProviderUI:(id<FUIAuthProvider>)providerUI
158158 // Sign out first to make sure sign in starts with a clean state.
159159 [providerUI signOut ];
160160 [providerUI signInWithDefaultValue: defaultValue
161- presentingViewController: presentingViewController
162- completion: ^(FIRAuthCredential *_Nullable credential,
163- NSError *_Nullable error,
164- _Nullable FIRAuthResultCallback result) {
161+ presentingViewController: presentingViewController
162+ completion: ^(FIRAuthCredential *_Nullable credential,
163+ NSError *_Nullable error,
164+ _Nullable FIRAuthResultCallback result) {
165165 BOOL isAuthPickerShown =
166166 [presentingViewController isKindOfClass: [FUIAuthPickerViewController class ]];
167167 if (error) {
@@ -177,12 +177,12 @@ - (void)signInWithProviderUI:(id<FUIAuthProvider>)providerUI
177177 [self .auth signInAndRetrieveDataWithCredential: credential
178178 completion: ^(FIRAuthDataResult *_Nullable authResult,
179179 NSError *_Nullable error) {
180- if (error && error .code == FIRAuthErrorCodeAccountExistsWithDifferentCredential) {
180+ if (error.code == FIRAuthErrorCodeAccountExistsWithDifferentCredential) {
181181 NSString *email = error.userInfo [kErrorUserInfoEmailKey ];
182182 [self handleAccountLinkingForEmail: email
183183 newCredential: credential
184184 presentingViewController: presentingViewController
185- singInResult : result];
185+ signInResult : result];
186186 return ;
187187 }
188188
@@ -208,10 +208,20 @@ - (void)signInWithProviderUI:(id<FUIAuthProvider>)providerUI
208208 }];
209209}
210210
211+ /* * @fn handleAccountLinkingForEmail:newCredential:presentingViewController:signInResult
212+ @brief Handles the account linking case after a user tries to sign-in which has a credential
213+ with an email which is already used by a different account.
214+ @param email The email address used by an existing account and and also the credential used in
215+ the sign-in attempt.
216+ @param newCredential The credential used in the lastest sign-in attempt.
217+ @param presentingViewController The view controller used to present the UI.
218+ @param signInResult block which takes the result of this method as a parameter; a nullable
219+ AuthResult indicating success or a nullable Error indicating failure.
220+ */
211221- (void )handleAccountLinkingForEmail : (NSString *)email
212222 newCredential : (FIRAuthCredential *)newCredential
213223 presentingViewController : (UIViewController *)presentingViewController
214- singInResult : (_Nullable FIRAuthResultCallback) result {
224+ signInResult : (_Nullable FIRAuthResultCallback)result {
215225
216226 [self .auth fetchProvidersForEmail: email
217227 completion: ^(NSArray <NSString *> *_Nullable providers,
0 commit comments