|
|
@@ -305,22 +305,22 @@ extern NSString *const FIRPhoneMultiFactorID;
|
|
|
return;
|
|
|
}
|
|
|
[_auth.notificationManager
|
|
|
- checkNotificationForwardingWithCallback:^(BOOL isNotificationBeingForwarded) {
|
|
|
- if (!isNotificationBeingForwarded) {
|
|
|
- completion(nil, [FIRAuthErrorUtils notificationNotForwardedError]);
|
|
|
- return;
|
|
|
- }
|
|
|
- FIRVerificationResultCallback callback =
|
|
|
- ^(NSString *_Nullable verificationID, NSError *_Nullable error) {
|
|
|
- if (completion) {
|
|
|
- completion(verificationID, error);
|
|
|
- }
|
|
|
- };
|
|
|
- [self verifyClientAndSendVerificationCodeToPhoneNumber:phoneNumber
|
|
|
- retryOnInvalidAppCredential:YES
|
|
|
- UIDelegate:UIDelegate
|
|
|
- callback:callback];
|
|
|
- }];
|
|
|
+ checkNotificationForwardingWithCallback:^(BOOL isNotificationBeingForwarded) {
|
|
|
+ if (!isNotificationBeingForwarded) {
|
|
|
+ completion(nil, [FIRAuthErrorUtils notificationNotForwardedError]);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ FIRVerificationResultCallback callback =
|
|
|
+ ^(NSString *_Nullable verificationID, NSError *_Nullable error) {
|
|
|
+ if (completion) {
|
|
|
+ completion(verificationID, error);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ [self verifyClientAndSendVerificationCodeToPhoneNumber:phoneNumber
|
|
|
+ retryOnInvalidAppCredential:YES
|
|
|
+ UIDelegate:UIDelegate
|
|
|
+ callback:callback];
|
|
|
+ }];
|
|
|
}
|
|
|
|
|
|
- (void)internalVerifyPhoneNumber:(NSString *)phoneNumber
|
|
|
@@ -334,25 +334,25 @@ extern NSString *const FIRPhoneMultiFactorID;
|
|
|
return;
|
|
|
}
|
|
|
[_auth.notificationManager
|
|
|
- checkNotificationForwardingWithCallback:^(BOOL isNotificationBeingForwarded) {
|
|
|
- if (!isNotificationBeingForwarded) {
|
|
|
- if (completion) {
|
|
|
- completion(nil, [FIRAuthErrorUtils notificationNotForwardedError]);
|
|
|
- }
|
|
|
- return;
|
|
|
+ checkNotificationForwardingWithCallback:^(BOOL isNotificationBeingForwarded) {
|
|
|
+ if (!isNotificationBeingForwarded) {
|
|
|
+ if (completion) {
|
|
|
+ completion(nil, [FIRAuthErrorUtils notificationNotForwardedError]);
|
|
|
}
|
|
|
- FIRVerificationResultCallback callback =
|
|
|
- ^(NSString *_Nullable verificationID, NSError *_Nullable error) {
|
|
|
- if (completion) {
|
|
|
- completion(verificationID, error);
|
|
|
- }
|
|
|
- };
|
|
|
- [self verifyClientAndSendVerificationCodeToPhoneNumber:phoneNumber
|
|
|
- retryOnInvalidAppCredential:YES
|
|
|
- UIDelegate:UIDelegate
|
|
|
- multiFactorSession:session
|
|
|
- callback:callback];
|
|
|
- }];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ FIRVerificationResultCallback callback =
|
|
|
+ ^(NSString *_Nullable verificationID, NSError *_Nullable error) {
|
|
|
+ if (completion) {
|
|
|
+ completion(verificationID, error);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ [self verifyClientAndSendVerificationCodeToPhoneNumber:phoneNumber
|
|
|
+ retryOnInvalidAppCredential:YES
|
|
|
+ UIDelegate:UIDelegate
|
|
|
+ multiFactorSession:session
|
|
|
+ callback:callback];
|
|
|
+ }];
|
|
|
}
|
|
|
|
|
|
/** @fn verifyClientAndSendVerificationCodeToPhoneNumber:retryOnInvalidAppCredential:callback:
|
|
|
@@ -381,66 +381,64 @@ extern NSString *const FIRPhoneMultiFactorID;
|
|
|
return;
|
|
|
}
|
|
|
[self
|
|
|
- verifyClientWithUIDelegate:UIDelegate
|
|
|
- completion:^(FIRAuthAppCredential *_Nullable appCredential,
|
|
|
- NSString *_Nullable reCAPTCHAToken, NSError *_Nullable error) {
|
|
|
- if (error) {
|
|
|
- callback(nil, error);
|
|
|
- return;
|
|
|
- }
|
|
|
- FIRSendVerificationCodeRequest *_Nullable request;
|
|
|
- if (appCredential) {
|
|
|
- request = [[FIRSendVerificationCodeRequest alloc]
|
|
|
- initWithPhoneNumber:phoneNumber
|
|
|
- appCredential:appCredential
|
|
|
- reCAPTCHAToken:nil
|
|
|
- requestConfiguration:self->_auth.requestConfiguration];
|
|
|
- } else if (reCAPTCHAToken) {
|
|
|
- request = [[FIRSendVerificationCodeRequest alloc]
|
|
|
- initWithPhoneNumber:phoneNumber
|
|
|
- appCredential:nil
|
|
|
- reCAPTCHAToken:reCAPTCHAToken
|
|
|
- requestConfiguration:self->_auth.requestConfiguration];
|
|
|
- }
|
|
|
- if (request) {
|
|
|
- [FIRAuthBackend
|
|
|
- sendVerificationCode:request
|
|
|
- callback:^(
|
|
|
- FIRSendVerificationCodeResponse *_Nullable response,
|
|
|
- NSError *_Nullable error) {
|
|
|
- if (error) {
|
|
|
- if (error.code ==
|
|
|
- FIRAuthErrorCodeInvalidAppCredential) {
|
|
|
- if (retryOnInvalidAppCredential) {
|
|
|
- [self->_auth
|
|
|
- .appCredentialManager clearCredential];
|
|
|
- [self
|
|
|
- verifyClientAndSendVerificationCodeToPhoneNumber:
|
|
|
- phoneNumber
|
|
|
- retryOnInvalidAppCredential:
|
|
|
- NO
|
|
|
- UIDelegate:
|
|
|
- UIDelegate
|
|
|
- callback:
|
|
|
- callback];
|
|
|
- return;
|
|
|
- }
|
|
|
- callback(
|
|
|
- nil,
|
|
|
- [FIRAuthErrorUtils
|
|
|
- unexpectedResponseWithDeserializedResponse:
|
|
|
- nil
|
|
|
- underlyingError:
|
|
|
- error]);
|
|
|
+ verifyClientWithUIDelegate:UIDelegate
|
|
|
+ completion:^(FIRAuthAppCredential *_Nullable appCredential,
|
|
|
+ NSString *_Nullable reCAPTCHAToken, NSError *_Nullable error) {
|
|
|
+ if (error) {
|
|
|
+ callback(nil, error);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ FIRSendVerificationCodeRequest *_Nullable request;
|
|
|
+ if (appCredential) {
|
|
|
+ request = [[FIRSendVerificationCodeRequest alloc]
|
|
|
+ initWithPhoneNumber:phoneNumber
|
|
|
+ appCredential:appCredential
|
|
|
+ reCAPTCHAToken:nil
|
|
|
+ requestConfiguration:self->_auth.requestConfiguration];
|
|
|
+ } else if (reCAPTCHAToken) {
|
|
|
+ request = [[FIRSendVerificationCodeRequest alloc]
|
|
|
+ initWithPhoneNumber:phoneNumber
|
|
|
+ appCredential:nil
|
|
|
+ reCAPTCHAToken:reCAPTCHAToken
|
|
|
+ requestConfiguration:self->_auth.requestConfiguration];
|
|
|
+ }
|
|
|
+ if (request) {
|
|
|
+ [FIRAuthBackend
|
|
|
+ sendVerificationCode:request
|
|
|
+ callback:^(
|
|
|
+ FIRSendVerificationCodeResponse *_Nullable response,
|
|
|
+ NSError *_Nullable error) {
|
|
|
+ if (error) {
|
|
|
+ if (error.code ==
|
|
|
+ FIRAuthErrorCodeInvalidAppCredential) {
|
|
|
+ if (retryOnInvalidAppCredential) {
|
|
|
+ [self->_auth.appCredentialManager clearCredential];
|
|
|
+ [self
|
|
|
+ verifyClientAndSendVerificationCodeToPhoneNumber:
|
|
|
+ phoneNumber
|
|
|
+ retryOnInvalidAppCredential:
|
|
|
+ NO
|
|
|
+ UIDelegate:
|
|
|
+ UIDelegate
|
|
|
+ callback:
|
|
|
+ callback];
|
|
|
return;
|
|
|
}
|
|
|
- callback(nil, error);
|
|
|
+ callback(
|
|
|
+ nil,
|
|
|
+ [FIRAuthErrorUtils
|
|
|
+ unexpectedResponseWithDeserializedResponse:nil
|
|
|
+ underlyingError:
|
|
|
+ error]);
|
|
|
return;
|
|
|
}
|
|
|
- callback(response.verificationID, nil);
|
|
|
- }];
|
|
|
- }
|
|
|
- }];
|
|
|
+ callback(nil, error);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ callback(response.verificationID, nil);
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ }];
|
|
|
}
|
|
|
|
|
|
- (void)verifyClientAndSendVerificationCodeToPhoneNumber:(NSString *)phoneNumber
|
|
|
@@ -463,128 +461,127 @@ extern NSString *const FIRPhoneMultiFactorID;
|
|
|
}
|
|
|
|
|
|
[self
|
|
|
- verifyClientWithUIDelegate:UIDelegate
|
|
|
- completion:^(FIRAuthAppCredential *_Nullable appCredential,
|
|
|
- NSString *_Nullable reCAPTCHAToken, NSError *_Nullable error) {
|
|
|
- if (error) {
|
|
|
- if (callback) {
|
|
|
- callback(nil, error);
|
|
|
- }
|
|
|
- return;
|
|
|
+ verifyClientWithUIDelegate:UIDelegate
|
|
|
+ completion:^(FIRAuthAppCredential *_Nullable appCredential,
|
|
|
+ NSString *_Nullable reCAPTCHAToken, NSError *_Nullable error) {
|
|
|
+ if (error) {
|
|
|
+ if (callback) {
|
|
|
+ callback(nil, error);
|
|
|
}
|
|
|
-
|
|
|
- NSString *IDToken = session.IDToken;
|
|
|
- FIRAuthProtoStartMFAPhoneRequestInfo *startMFARequestInfo =
|
|
|
- [[FIRAuthProtoStartMFAPhoneRequestInfo alloc]
|
|
|
- initWithPhoneNumber:phoneNumber
|
|
|
- appCredential:appCredential
|
|
|
- reCAPTCHAToken:reCAPTCHAToken];
|
|
|
- if (session.IDToken) {
|
|
|
- FIRStartMFAEnrollmentRequest *request =
|
|
|
- [[FIRStartMFAEnrollmentRequest alloc]
|
|
|
- initWithIDToken:IDToken
|
|
|
- enrollmentInfo:startMFARequestInfo
|
|
|
- requestConfiguration:self->_auth.requestConfiguration];
|
|
|
- [FIRAuthBackend
|
|
|
- startMultiFactorEnrollment:request
|
|
|
- callback:^(FIRStartMFAEnrollmentResponse
|
|
|
- *_Nullable response,
|
|
|
- NSError *_Nullable error) {
|
|
|
- if (error) {
|
|
|
- if (error.code ==
|
|
|
- FIRAuthErrorCodeInvalidAppCredential) {
|
|
|
- if (retryOnInvalidAppCredential) {
|
|
|
- [self->_auth.appCredentialManager
|
|
|
- clearCredential];
|
|
|
- [self
|
|
|
- verifyClientAndSendVerificationCodeToPhoneNumber:
|
|
|
- phoneNumber
|
|
|
- retryOnInvalidAppCredential:
|
|
|
- NO
|
|
|
- UIDelegate:
|
|
|
- UIDelegate
|
|
|
- multiFactorSession:
|
|
|
- session
|
|
|
- callback:
|
|
|
- callback];
|
|
|
- return;
|
|
|
- }
|
|
|
- if (callback) {
|
|
|
- callback(
|
|
|
- nil,
|
|
|
- [FIRAuthErrorUtils
|
|
|
- unexpectedResponseWithDeserializedResponse:
|
|
|
- nil
|
|
|
- underlyingError:
|
|
|
- error]);
|
|
|
- }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ NSString *IDToken = session.IDToken;
|
|
|
+ FIRAuthProtoStartMFAPhoneRequestInfo *startMFARequestInfo =
|
|
|
+ [[FIRAuthProtoStartMFAPhoneRequestInfo alloc]
|
|
|
+ initWithPhoneNumber:phoneNumber
|
|
|
+ appCredential:appCredential
|
|
|
+ reCAPTCHAToken:reCAPTCHAToken];
|
|
|
+ if (session.IDToken) {
|
|
|
+ FIRStartMFAEnrollmentRequest *request =
|
|
|
+ [[FIRStartMFAEnrollmentRequest alloc]
|
|
|
+ initWithIDToken:IDToken
|
|
|
+ enrollmentInfo:startMFARequestInfo
|
|
|
+ requestConfiguration:self->_auth.requestConfiguration];
|
|
|
+ [FIRAuthBackend
|
|
|
+ startMultiFactorEnrollment:request
|
|
|
+ callback:^(
|
|
|
+ FIRStartMFAEnrollmentResponse *_Nullable response,
|
|
|
+ NSError *_Nullable error) {
|
|
|
+ if (error) {
|
|
|
+ if (error.code ==
|
|
|
+ FIRAuthErrorCodeInvalidAppCredential) {
|
|
|
+ if (retryOnInvalidAppCredential) {
|
|
|
+ [self->_auth.appCredentialManager
|
|
|
+ clearCredential];
|
|
|
+ [self
|
|
|
+ verifyClientAndSendVerificationCodeToPhoneNumber:
|
|
|
+ phoneNumber
|
|
|
+ retryOnInvalidAppCredential:
|
|
|
+ NO
|
|
|
+ UIDelegate:
|
|
|
+ UIDelegate
|
|
|
+ multiFactorSession:
|
|
|
+ session
|
|
|
+ callback:
|
|
|
+ callback];
|
|
|
return;
|
|
|
- } else {
|
|
|
- if (callback) {
|
|
|
- callback(nil, error);
|
|
|
- }
|
|
|
}
|
|
|
- } else {
|
|
|
if (callback) {
|
|
|
callback(
|
|
|
- response.enrollmentResponse.sessionInfo,
|
|
|
- nil);
|
|
|
+ nil,
|
|
|
+ [FIRAuthErrorUtils
|
|
|
+ unexpectedResponseWithDeserializedResponse:
|
|
|
+ nil
|
|
|
+ underlyingError:
|
|
|
+ error]);
|
|
|
}
|
|
|
- }
|
|
|
- }];
|
|
|
- } else {
|
|
|
- FIRStartMFASignInRequest *request = [[FIRStartMFASignInRequest alloc]
|
|
|
- initWithMFAPendingCredential:session.MFAPendingCredential
|
|
|
- MFAEnrollmentID:session.multiFactorInfo.UID
|
|
|
- signInInfo:startMFARequestInfo
|
|
|
- requestConfiguration:self->_auth.requestConfiguration];
|
|
|
- [FIRAuthBackend
|
|
|
- startMultiFactorSignIn:request
|
|
|
- callback:^(
|
|
|
- FIRStartMFASignInResponse *_Nullable response,
|
|
|
- NSError *_Nullable error) {
|
|
|
- if (error) {
|
|
|
- if (error.code ==
|
|
|
- FIRAuthErrorCodeInvalidAppCredential) {
|
|
|
- if (retryOnInvalidAppCredential) {
|
|
|
- [self->_auth
|
|
|
- .appCredentialManager clearCredential];
|
|
|
- [self
|
|
|
- verifyClientAndSendVerificationCodeToPhoneNumber:
|
|
|
- phoneNumber
|
|
|
- retryOnInvalidAppCredential:
|
|
|
- NO
|
|
|
- UIDelegate:
|
|
|
- UIDelegate
|
|
|
- multiFactorSession:
|
|
|
- session
|
|
|
- callback:
|
|
|
- callback];
|
|
|
return;
|
|
|
+ } else {
|
|
|
+ if (callback) {
|
|
|
+ callback(nil, error);
|
|
|
+ }
|
|
|
}
|
|
|
+ } else {
|
|
|
if (callback) {
|
|
|
callback(
|
|
|
- nil,
|
|
|
- [FIRAuthErrorUtils
|
|
|
- unexpectedResponseWithDeserializedResponse:
|
|
|
- nil
|
|
|
- underlyingError:
|
|
|
- error]);
|
|
|
+ response.enrollmentResponse.sessionInfo,
|
|
|
+ nil);
|
|
|
}
|
|
|
+ }
|
|
|
+ }];
|
|
|
+ } else {
|
|
|
+ FIRStartMFASignInRequest *request = [[FIRStartMFASignInRequest alloc]
|
|
|
+ initWithMFAPendingCredential:session.MFAPendingCredential
|
|
|
+ MFAEnrollmentID:session.multiFactorInfo.UID
|
|
|
+ signInInfo:startMFARequestInfo
|
|
|
+ requestConfiguration:self->_auth.requestConfiguration];
|
|
|
+ [FIRAuthBackend
|
|
|
+ startMultiFactorSignIn:request
|
|
|
+ callback:^(FIRStartMFASignInResponse *_Nullable response,
|
|
|
+ NSError *_Nullable error) {
|
|
|
+ if (error) {
|
|
|
+ if (error.code ==
|
|
|
+ FIRAuthErrorCodeInvalidAppCredential) {
|
|
|
+ if (retryOnInvalidAppCredential) {
|
|
|
+ [self->_auth
|
|
|
+ .appCredentialManager clearCredential];
|
|
|
+ [self
|
|
|
+ verifyClientAndSendVerificationCodeToPhoneNumber:
|
|
|
+ phoneNumber
|
|
|
+ retryOnInvalidAppCredential:
|
|
|
+ NO
|
|
|
+ UIDelegate:
|
|
|
+ UIDelegate
|
|
|
+ multiFactorSession:
|
|
|
+ session
|
|
|
+ callback:
|
|
|
+ callback];
|
|
|
return;
|
|
|
- } else {
|
|
|
- if (callback) {
|
|
|
- callback(nil, error);
|
|
|
- }
|
|
|
}
|
|
|
+ if (callback) {
|
|
|
+ callback(
|
|
|
+ nil,
|
|
|
+ [FIRAuthErrorUtils
|
|
|
+ unexpectedResponseWithDeserializedResponse:
|
|
|
+ nil
|
|
|
+ underlyingError:
|
|
|
+ error]);
|
|
|
+ }
|
|
|
+ return;
|
|
|
} else {
|
|
|
if (callback) {
|
|
|
- callback(response.responseInfo.sessionInfo, nil);
|
|
|
+ callback(nil, error);
|
|
|
}
|
|
|
}
|
|
|
- }];
|
|
|
- }
|
|
|
- }];
|
|
|
+ } else {
|
|
|
+ if (callback) {
|
|
|
+ callback(response.responseInfo.sessionInfo, nil);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ }];
|
|
|
}
|
|
|
|
|
|
/** @fn verifyClientWithCompletion:completion:
|