Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Auth] Restore User decoding to pre-11 behavior #14069

Merged
merged 2 commits into from
Nov 9, 2024
Merged

Conversation

ncooke3
Copy link
Member

@ncooke3 ncooke3 commented Nov 8, 2024

The logging out was happening because the User.init(coder:) implementation in Firebase 11 was returning nil for cases where it previously hadn't in previous major versions.

Firebase 11 returned nil when any of the following was nil:

guard let userID = coder.decodeObject(of: NSString.self, forKey: kUserIDCodingKey) as? String,
let apiKey = coder.decodeObject(of: NSString.self, forKey: kAPIKeyCodingKey) as? String,
let appID = coder.decodeObject(
of: NSString.self,
forKey: kFirebaseAppIDCodingKey
) as? String,
let tokenService = coder.decodeObject(of: SecureTokenService.self,
forKey: kTokenServiceCodingKey) else {
return nil
}

But Firebase 10.29.0 returned nil in only 2 cases:

if (!userID || !tokenService) {
return nil;
}

PR #9046 started encoding an app ID key to the user's archived format and that was first released in 8.11.0, so when updating from < 8.11 to 11+, the user instance would fail decoding with the early exit since the app ID couldn't be unarchived.

This failed silently through Firebase 10 because the Objective-C impl. didn't early exit and a nil decoding was silently allowed.

Testing:

  1. Auth QS with 8.8 -> sign in with a user
  2. Auth QS with 11.4 -> confirmed user is logged out
  3. Auth QS with 11.4 with this fix -> confirmed user logs in at app startup

Fixes #14011

#no-changelog

Copy link
Member

@paulb777 paulb777 left a comment

Choose a reason for hiding this comment

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

Great find! I'll merge to get it into the nightlies.

@paulb777 paulb777 merged commit a31400d into main Nov 9, 2024
55 checks passed
@paulb777 paulb777 deleted the nc/fix-user-decode branch November 9, 2024 00:43
@JCsplash
Copy link

JCsplash commented Nov 9, 2024

@paulb777 Thanks for merging! How long does it take for this fix to get into a stable release? Should we wait until 11.5.0 is officially released to update our pod?

@paulb777
Copy link
Member

paulb777 commented Nov 9, 2024

We'll sort out the release plan for the fix early next week.

It's up to you if you want to wait for the release or patch the fix into your current build.

@andrewheard andrewheard added this to the 11.5.0 - M156 milestone Nov 11, 2024
@firebase firebase locked and limited conversation to collaborators Dec 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrading to 11.0.0+ causes user to get logged out.
5 participants