Skip to content

Commit fd5d501

Browse files
committed
[Auth] Restore User decoding to pre-11 behavior
1 parent 0aca0bf commit fd5d501

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

FirebaseAuth/Sources/Swift/User/User.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,11 +1704,6 @@ extension User: NSSecureCoding {}
17041704

17051705
public required init?(coder: NSCoder) {
17061706
guard let userID = coder.decodeObject(of: NSString.self, forKey: kUserIDCodingKey) as? String,
1707-
let apiKey = coder.decodeObject(of: NSString.self, forKey: kAPIKeyCodingKey) as? String,
1708-
let appID = coder.decodeObject(
1709-
of: NSString.self,
1710-
forKey: kFirebaseAppIDCodingKey
1711-
) as? String,
17121707
let tokenService = coder.decodeObject(of: SecureTokenService.self,
17131708
forKey: kTokenServiceCodingKey) else {
17141709
return nil
@@ -1746,8 +1741,17 @@ extension User: NSSecureCoding {}
17461741
self.phoneNumber = phoneNumber
17471742
self.metadata = metadata ?? UserMetadata(withCreationDate: nil, lastSignInDate: nil)
17481743
self.tenantID = tenantID
1749-
// The `heartbeatLogger` and `appCheck` will be set later via a property update.
1750-
requestConfiguration = AuthRequestConfiguration(apiKey: apiKey, appID: appID)
1744+
1745+
// Note, in practice, the caller will set the `auth` property of this user
1746+
// instance which will as a side-effect overwrite the request configuration.
1747+
// The assignment here is a best-effort placeholder.
1748+
let apiKey = coder.decodeObject(of: NSString.self, forKey: kAPIKeyCodingKey) as? String
1749+
let appID = coder.decodeObject(
1750+
of: NSString.self,
1751+
forKey: kFirebaseAppIDCodingKey
1752+
) as? String
1753+
requestConfiguration = AuthRequestConfiguration(apiKey: apiKey ?? "", appID: appID ?? "")
1754+
17511755
userProfileUpdate = UserProfileUpdate()
17521756
#if os(iOS)
17531757
self.multiFactor = multiFactor ?? MultiFactor()

0 commit comments

Comments
 (0)