|
18 | 18 | #import "FIRAuthDataResult.h"
|
19 | 19 | #import "FIRAuthErrors.h"
|
20 | 20 | #import "FIROptions.h"
|
| 21 | +#import "FIROAuthCredential.h" |
21 | 22 |
|
22 | 23 | #include "app/src/app_ios.h"
|
23 | 24 | #include "app/src/assert.h"
|
@@ -118,6 +119,18 @@ @implementation FIRCPPAuthListenerHandle
|
118 | 119 | // kAuthErrorEmailChangeNeedsVerification},
|
119 | 120 | };
|
120 | 121 |
|
| 122 | +// A provider that wraps a Credential returned from the Firebase iOS SDK which may occur when a |
| 123 | +// nonce based link failure occurs due to a pre-existing account already linked with a Provider. |
| 124 | +// This credential may be used to attempt to sign into Firebase using that account. |
| 125 | +class ServiceUpdatedCredentialProvider { |
| 126 | + public: |
| 127 | + // Construct a Credential given a preexisting FIRAuthCredential wrapped by a |
| 128 | + // FIRAuthCredentialPointer. |
| 129 | + static Credential GetCredential(FIRAuthCredentialPointer* impl) { |
| 130 | + return Credential(impl); |
| 131 | + } |
| 132 | +}; |
| 133 | + |
121 | 134 | template<typename T>
|
122 | 135 | struct ListenerHandleHolder {
|
123 | 136 | explicit ListenerHandleHolder(T handle) : handle(handle) {}
|
@@ -315,6 +328,13 @@ void SignInResultCallback(FIRAuthDataResult *_Nullable auth_result, NSError *_Nu
|
315 | 328 | util::NSDictionaryToStdMap(auth_result.additionalUserInfo.profile, &result.info.profile);
|
316 | 329 | }
|
317 | 330 |
|
| 331 | + if (error.userInfo != nullptr) { |
| 332 | + if (error.userInfo[FIRAuthErrorUserInfoUpdatedCredentialKey] != nullptr) { |
| 333 | + result.info.updated_credential = ServiceUpdatedCredentialProvider::GetCredential( |
| 334 | + new FIRAuthCredentialPointer(error.userInfo[FIRAuthErrorUserInfoUpdatedCredentialKey])); |
| 335 | + } |
| 336 | + } |
| 337 | + |
318 | 338 | ReferenceCountedFutureImpl &futures = auth_data->future_impl;
|
319 | 339 | futures.CompleteWithResult(handle, AuthErrorFromNSError(error),
|
320 | 340 | util::NSStringToString(error.localizedDescription).c_str(), result);
|
|
0 commit comments