Skip to content

Commit 458919f

Browse files
authored
Fix combined error and completion handling (#11225)
1 parent 3fcb8df commit 458919f

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

FirebaseAuth/Sources/Auth/FIRAuth.m

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,11 +1537,11 @@ - (void)revokeTokenWithAuthorizationCode:(NSString *)authorizationCode
15371537
completion:(nullable void (^)(NSError *_Nullable error))completion {
15381538
[self.currentUser
15391539
getIDTokenWithCompletion:^(NSString *_Nullable idToken, NSError *_Nullable error) {
1540-
if (completion) {
1541-
if (error) {
1540+
if (error) {
1541+
if (completion) {
15421542
completion(error);
1543-
return;
15441543
}
1544+
return;
15451545
}
15461546
FIRRevokeTokenRequest *request =
15471547
[[FIRRevokeTokenRequest alloc] initWithToken:authorizationCode
@@ -1703,8 +1703,7 @@ - (void)signInWithPhoneCredential:(FIRPhoneAuthCredential *)credential
17031703
@param completion A block which is invoked when the custom token sign in request completes.
17041704
*/
17051705
- (void)internalSignInAndRetrieveDataWithCustomToken:(NSString *)token
1706-
completion:
1707-
(nullable FIRAuthDataResultCallback)completion {
1706+
completion:(FIRAuthDataResultCallback)completion {
17081707
FIRVerifyCustomTokenRequest *request =
17091708
[[FIRVerifyCustomTokenRequest alloc] initWithToken:token
17101709
requestConfiguration:_requestConfiguration];
@@ -1713,18 +1712,16 @@ - (void)internalSignInAndRetrieveDataWithCustomToken:(NSString *)token
17131712
callback:^(FIRVerifyCustomTokenResponse *_Nullable response,
17141713
NSError *_Nullable error) {
17151714
if (error) {
1716-
if (completion) {
1717-
completion(nil, error);
1718-
return;
1719-
}
1715+
completion(nil, error);
1716+
return;
17201717
}
17211718
[self completeSignInWithAccessToken:response.IDToken
17221719
accessTokenExpirationDate:response.approximateExpirationDate
17231720
refreshToken:response.refreshToken
17241721
anonymous:NO
17251722
callback:^(FIRUser *_Nullable user,
17261723
NSError *_Nullable error) {
1727-
if (error && completion) {
1724+
if (error) {
17281725
completion(nil, error);
17291726
return;
17301727
}
@@ -1739,9 +1736,7 @@ - (void)internalSignInAndRetrieveDataWithCustomToken:(NSString *)token
17391736
initWithUser:user
17401737
additionalUserInfo:additonalUserInfo]
17411738
: nil;
1742-
if (completion) {
1743-
completion(result, error);
1744-
}
1739+
completion(result, error);
17451740
}];
17461741
}];
17471742
}

0 commit comments

Comments
 (0)