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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions FirebaseAuth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Unreleased
ncooke3 marked this conversation as resolved.
Show resolved Hide resolved
- [fixed] Restore pre-Firebase 11 decoding behavior to prevent users getting
logged out when upgrading from Firebase 8.10.0 or earlier to Firebase 11.
(#14011)

# 11.4.0
- [fixed] Restore Firebase 10 behavior by ignoring `nil` display names used
during multi factor enrollment. (#13856)
Expand Down
18 changes: 11 additions & 7 deletions FirebaseAuth/Sources/Swift/User/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1704,11 +1704,6 @@ extension User: NSSecureCoding {}

public required init?(coder: NSCoder) {
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
Expand Down Expand Up @@ -1746,8 +1741,17 @@ extension User: NSSecureCoding {}
self.phoneNumber = phoneNumber
self.metadata = metadata ?? UserMetadata(withCreationDate: nil, lastSignInDate: nil)
self.tenantID = tenantID
// The `heartbeatLogger` and `appCheck` will be set later via a property update.
requestConfiguration = AuthRequestConfiguration(apiKey: apiKey, appID: appID)

// Note, in practice, the caller will set the `auth` property of this user
// instance which will as a side-effect overwrite the request configuration.
// The assignment here is a best-effort placeholder.
let apiKey = coder.decodeObject(of: NSString.self, forKey: kAPIKeyCodingKey) as? String
let appID = coder.decodeObject(
of: NSString.self,
forKey: kFirebaseAppIDCodingKey
) as? String
requestConfiguration = AuthRequestConfiguration(apiKey: apiKey ?? "", appID: appID ?? "")

userProfileUpdate = UserProfileUpdate()
#if os(iOS)
self.multiFactor = multiFactor ?? MultiFactor()
Expand Down
Loading