Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix user session persistence in multi tenant projects #13567

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading