Skip to content

Commit

Permalink
Fix user session persistence in multi tenant projects (#13567)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 authored Sep 3, 2024
1 parent 7700b58 commit d1b950f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions FirebaseAuth/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
- [Fixed] Fixed crashes that could occur in Swift continuation blocks running in the Xcode 16
betas. (#13480)
- [Fixed] Fixed Phone Auth via Sandbox APNS tokens that broke in 11.0.0. (#13479)
- [Fixed] Fix crash when fetching sign in methods due to unexpected nil.
- [Fixed] Fixed crash when fetching sign in methods due to unexpected nil.
Previously, fetching sign in methods could return both a `nil` array of sign
in methods and a `nil` error. In such cases, an empty array is instead
returned with the `nil` error. (#13550)

- [Fixed] Fixed user session persistence in multi tenant projects. Introduced in 11.0.0. (#13565)

# 11.1.0
- [fixed] Fixed `Swift.error` conformance for `AuthErrorCode`. (#13430)
Expand Down
7 changes: 4 additions & 3 deletions FirebaseAuth/Sources/Swift/Auth/Auth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1667,9 +1667,11 @@ extension Auth: AuthInterop {
try self.internalUseUserAccessGroup(storedUserAccessGroup)
} else {
let user = try self.getUser()
try self.updateCurrentUser(user, byForce: false, savingToDisk: false)
if let user {
self.tenantID = user.tenantID
}
try self.updateCurrentUser(user, byForce: false, savingToDisk: false)
if let user {
self.lastNotifiedUserToken = user.rawAccessToken()
}
}
Expand Down Expand Up @@ -1941,8 +1943,7 @@ extension Auth: AuthInterop {
}
if let user {
if user.tenantID != nil || tenantID != nil, tenantID != user.tenantID {
let error = AuthErrorUtils.tenantIDMismatchError()
throw error
throw AuthErrorUtils.tenantIDMismatchError()
}
}
var throwError: Error?
Expand Down
3 changes: 1 addition & 2 deletions FirebaseAuth/Sources/Swift/Backend/AuthBackend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,7 @@ private class AuthBackendRPCImplementation: NSObject, AuthBackendImplementation
code: AuthErrorCode.maximumSecondFactorCountExceeded,
message: serverDetailErrorMessage
)
case "TENANT_ID_MISMATCH": return AuthErrorUtils
.tenantIDMismatchError()
case "TENANT_ID_MISMATCH": return AuthErrorUtils.tenantIDMismatchError()
case "TOKEN_EXPIRED": return AuthErrorUtils
.userTokenExpiredError(message: serverDetailErrorMessage)
case "UNSUPPORTED_FIRST_FACTOR": return AuthErrorUtils
Expand Down

0 comments on commit d1b950f

Please sign in to comment.