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] Fix Multi-factor session crash on second Firebase app #14238

Merged
merged 2 commits into from
Dec 10, 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
1 change: 1 addition & 0 deletions FirebaseAuth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Unreleased
- [fixed] Fix Multi-factor session crash on second Firebase app. (#14238)
- [fixed] Updated most decoders to be consistent with Firebase 10's behavior
for decoding `nil` values. (#14212)

Expand Down
2 changes: 1 addition & 1 deletion FirebaseAuth/Sources/Swift/MultiFactor/MultiFactor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import Foundation
/// operation.
@objc(getSessionWithCompletion:)
open func getSessionWithCompletion(_ completion: ((MultiFactorSession?, Error?) -> Void)?) {
let session = MultiFactorSession.sessionForCurrentUser
let session = MultiFactorSession.session(for: user)
if let completion {
completion(session, nil)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ import Foundation
/// Current user object.
var currentUser: User?

class var sessionForCurrentUser: MultiFactorSession {
guard let currentUser = Auth.auth().currentUser else {
class func session(for user: User?) -> MultiFactorSession {
let currentUser = user ?? Auth.auth().currentUser
guard let currentUser else {
fatalError("Internal Auth Error: missing user for multifactor auth")
}
return .init(idToken: currentUser.tokenService.accessToken, currentUser: currentUser)
Expand Down
Loading