Skip to content

Commit

Permalink
[auth] Fix Multi-factor session crash on second Firebase app (#14238)
Browse files Browse the repository at this point in the history
Co-authored-by: Nick Cooke <[email protected]>
  • Loading branch information
paulb777 and ncooke3 authored Dec 10, 2024
1 parent acc4bbf commit 44ab3a9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
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

0 comments on commit 44ab3a9

Please sign in to comment.