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
+
1
5
# 11.9.0
2
6
- [ changed] Using reCAPTCHA Enterprise and Firebase Auth requires reCAPTCHA
3
7
Enterprise 18.7.0 or later.
Original file line number Diff line number Diff line change @@ -1081,7 +1081,7 @@ extension User: NSSecureCoding {}
1081
1081
anonymous: Bool ) async throws -> User {
1082
1082
guard let accessToken = accessToken,
1083
1083
let refreshToken = refreshToken else {
1084
- fatalError ( " Internal FirebaseAuth Error: nil token " )
1084
+ throw AuthErrorUtils . invalidUserTokenError ( message : " Invalid user token: accessToken or refreshToken is nil " )
1085
1085
}
1086
1086
let tokenService = SecureTokenService ( withRequestConfiguration: auth. requestConfiguration,
1087
1087
accessToken: accessToken,
Original file line number Diff line number Diff line change @@ -1554,6 +1554,23 @@ class UserTests: RPCBaseTests {
1554
1554
}
1555
1555
#endif
1556
1556
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
+
1557
1574
// MARK: Private helper functions
1558
1575
1559
1576
private func expectVerifyPhoneNumberRequest( isLink: Bool = false ) {
You can’t perform that action at this time.
0 commit comments