@@ -158,10 +158,10 @@ - (void)signInWithProviderUI:(id<FUIAuthProvider>)providerUI
158
158
// Sign out first to make sure sign in starts with a clean state.
159
159
[providerUI signOut ];
160
160
[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) {
165
165
BOOL isAuthPickerShown =
166
166
[presentingViewController isKindOfClass: [FUIAuthPickerViewController class ]];
167
167
if (error) {
@@ -177,12 +177,12 @@ - (void)signInWithProviderUI:(id<FUIAuthProvider>)providerUI
177
177
[self .auth signInAndRetrieveDataWithCredential: credential
178
178
completion: ^(FIRAuthDataResult *_Nullable authResult,
179
179
NSError *_Nullable error) {
180
- if (error && error .code == FIRAuthErrorCodeAccountExistsWithDifferentCredential) {
180
+ if (error.code == FIRAuthErrorCodeAccountExistsWithDifferentCredential) {
181
181
NSString *email = error.userInfo [kErrorUserInfoEmailKey ];
182
182
[self handleAccountLinkingForEmail: email
183
183
newCredential: credential
184
184
presentingViewController: presentingViewController
185
- singInResult : result];
185
+ signInResult : result];
186
186
return ;
187
187
}
188
188
@@ -208,10 +208,20 @@ - (void)signInWithProviderUI:(id<FUIAuthProvider>)providerUI
208
208
}];
209
209
}
210
210
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
+ */
211
221
- (void )handleAccountLinkingForEmail : (NSString *)email
212
222
newCredential : (FIRAuthCredential *)newCredential
213
223
presentingViewController : (UIViewController *)presentingViewController
214
- singInResult : (_Nullable FIRAuthResultCallback) result {
224
+ signInResult : (_Nullable FIRAuthResultCallback)result {
215
225
216
226
[self .auth fetchProvidersForEmail: email
217
227
completion: ^(NSArray <NSString *> *_Nullable providers,
0 commit comments