Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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,13 @@ 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 = if user != nil {
user
} else {
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