File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 1+ # Unreleased
2+ - [ fixed] Fix a ` fatalError ` unenrolling from MFA. An invalid user token now throws an
3+ ` invalidUserToken ` error instead of crashing. (#14663 )
4+
15# 11.9.0
26- [ changed] Using reCAPTCHA Enterprise and Firebase Auth requires reCAPTCHA
37 Enterprise 18.7.0 or later.
Original file line number Diff line number Diff line change @@ -1081,7 +1081,7 @@ extension User: NSSecureCoding {}
10811081 anonymous: Bool ) async throws -> User {
10821082 guard let accessToken = accessToken,
10831083 let refreshToken = refreshToken else {
1084- fatalError ( " Internal FirebaseAuth Error: nil token " )
1084+ throw AuthErrorUtils . invalidUserTokenError ( message : " Invalid user token: accessToken or refreshToken is nil " )
10851085 }
10861086 let tokenService = SecureTokenService ( withRequestConfiguration: auth. requestConfiguration,
10871087 accessToken: accessToken,
Original file line number Diff line number Diff line change @@ -1554,6 +1554,23 @@ class UserTests: RPCBaseTests {
15541554 }
15551555 #endif
15561556
1557+ func testRetrieveUserWithInvalidToken( ) async throws {
1558+ let auth = try XCTUnwrap ( self . auth)
1559+ do {
1560+ _ = try await User . retrieveUser (
1561+ withAuth: auth,
1562+ accessToken: nil ,
1563+ accessTokenExpirationDate: Date ( ) ,
1564+ refreshToken: nil ,
1565+ anonymous: false
1566+ )
1567+ XCTFail ( " Expected an error to be thrown " )
1568+ } catch let error as NSError {
1569+ XCTAssertEqual ( error. domain, AuthErrors . domain)
1570+ XCTAssertEqual ( error. code, AuthErrorCode . invalidUserToken. rawValue)
1571+ }
1572+ }
1573+
15571574 // MARK: Private helper functions
15581575
15591576 private func expectVerifyPhoneNumberRequest( isLink: Bool = false ) {
You can’t perform that action at this time.
0 commit comments