Skip to content

Commit ec108bb

Browse files
authored
[auth] Fix logic inconsistency between 10.x and 11.x (#14067)
1 parent a24e57c commit ec108bb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

FirebaseAuth/Sources/Swift/User/User.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,18 +1598,22 @@ extension User: NSSecureCoding {}
15981598
/// Retrieves the Firebase authentication token, possibly refreshing it if it has expired.
15991599
/// - Parameter forceRefresh
16001600
func internalGetTokenAsync(forceRefresh: Bool = false) async throws -> String {
1601+
var keychainError = false
16011602
do {
16021603
let (token, tokenUpdated) = try await tokenService.fetchAccessToken(
16031604
forcingRefresh: forceRefresh
16041605
)
16051606
if tokenUpdated {
16061607
if let error = updateKeychain() {
1608+
keychainError = true
16071609
throw error
16081610
}
16091611
}
16101612
return token!
16111613
} catch {
1612-
signOutIfTokenIsInvalid(withError: error)
1614+
if !keychainError {
1615+
signOutIfTokenIsInvalid(withError: error)
1616+
}
16131617
throw error
16141618
}
16151619
}

0 commit comments

Comments
 (0)