Skip to content

[auth] Fix logic inconsistency between 10.x and 11.x #14067

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

paulb777
Copy link
Member

@paulb777 paulb777 commented Nov 8, 2024

While investigating #14026 I found the following logic inconsistency after a keychain error in internalGetTokenAsync. It was potentially signing out when Firebase 10 did not.

I'm not sure how this could cause #14026, but we should keep the logic consistent.

I'm also open to suggestions about a cleaner solution that doesn't require the new flag.

Here's the Firebase 10 version:

- (void)internalGetTokenForcingRefresh:(BOOL)forceRefresh
                              callback:(nonnull FIRAuthTokenCallback)callback {
  [_tokenService fetchAccessTokenForcingRefresh:forceRefresh
                                       callback:^(NSString *_Nullable token,
                                                  NSError *_Nullable error, BOOL tokenUpdated) {
                                         if (error) {
                                           [self signOutIfTokenIsInvalidWithError:error];
                                           callback(nil, error);
                                           return;
                                         }
                                         if (tokenUpdated) {
                                           if (![self updateKeychain:&error]) {
                                             callback(nil, error);
                                             return;
                                           }
                                         }
                                         callback(token, nil);
                                       }];
}

@paulb777 paulb777 changed the title Fix logic inconsistency between 10.x and 11.x [auth] Fix logic inconsistency between 10.x and 11.x Nov 8, 2024
@google-oss-bot
Copy link

1 Warning
⚠️ Did you forget to add a changelog entry? (Add #no-changelog to the PR description to silence this warning.)

Generated by 🚫 Danger

Copy link
Member

@ncooke3 ncooke3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find!

@paulb777 paulb777 merged commit ec108bb into main Nov 11, 2024
55 checks passed
@paulb777 paulb777 deleted the pb-token-ten-to-eleven-logic-consistency-fix branch November 11, 2024 15:38
andrewheard added a commit that referenced this pull request Nov 11, 2024
@andrewheard andrewheard added this to the 11.5.0 - M156 milestone Nov 11, 2024
andrewheard added a commit that referenced this pull request Nov 11, 2024
@firebase firebase locked and limited conversation to collaborators Dec 12, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants