@iblai/web-utils 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -3
- package/dist/index.esm.js +32 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +32 -1
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/web-utils/src/providers/tenant-provider.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2852,6 +2852,11 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2852
2852
|
console.log("[AuthProvider] Redirect already in progress, skipping");
|
|
2853
2853
|
return;
|
|
2854
2854
|
}
|
|
2855
|
+
// Skip if a tenant switch is already in progress
|
|
2856
|
+
if (isWeb$1() && document.cookie.includes("ibl_tenant_switching")) {
|
|
2857
|
+
console.log("[AuthProvider] Tenant switch in progress, skipping redirect");
|
|
2858
|
+
return;
|
|
2859
|
+
}
|
|
2855
2860
|
isRedirectingRef.current = true;
|
|
2856
2861
|
// NOTE: we intentionally do NOT clear the interval here.
|
|
2857
2862
|
// The isRedirectingRef guard prevents redundant redirects while navigation
|
|
@@ -2947,6 +2952,8 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2947
2952
|
needsRefresh,
|
|
2948
2953
|
userDataOutOfSync,
|
|
2949
2954
|
pathname,
|
|
2955
|
+
currentLogoutTimestamp,
|
|
2956
|
+
lastLogoutTimestampRef: lastLogoutTimestampRef.current,
|
|
2950
2957
|
});
|
|
2951
2958
|
if (needsRefresh) {
|
|
2952
2959
|
console.log("[auth-redirect] Cookie sync detected changes from another SPA, refreshing page");
|
|
@@ -3223,7 +3230,7 @@ const useTenantContext = () => React.useContext(TenantContext);
|
|
|
3223
3230
|
* 4. Handles tenant-specific domain redirects
|
|
3224
3231
|
* 5. Maintains tenant access state
|
|
3225
3232
|
*/
|
|
3226
|
-
function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, currentTenant, requestedTenant, saveCurrentTenant, saveUserTenants, handleTenantSwitch, saveVisitingTenant, removeVisitingTenant, saveUserTokens, saveTenant, onAutoJoinUserToTenant, redirectToAuthSpa, username, isIframed = false, setUseMentorProvider, skip = false, onLoadPlatformPermissions, skipCustomDomainCheck = false, }) {
|
|
3233
|
+
function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, currentTenant, requestedTenant, saveCurrentTenant, saveUserTenants, handleTenantSwitch, saveVisitingTenant, removeVisitingTenant, saveUserTokens, saveTenant, onAutoJoinUserToTenant, redirectToAuthSpa, username, isIframed = false, setUseMentorProvider, skip = false, onLoadPlatformPermissions, skipCustomDomainCheck = false, onTenantMismatch = () => { }, }) {
|
|
3227
3234
|
// If skip is true, just return children without any provider logic
|
|
3228
3235
|
if (skip) {
|
|
3229
3236
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: children });
|
|
@@ -3654,6 +3661,30 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
|
|
|
3654
3661
|
isLoadingCustomDomain,
|
|
3655
3662
|
isCustomDomainError,
|
|
3656
3663
|
]);
|
|
3664
|
+
// Poll every 2s: if requestedTenant exists, differs from currentTenant,
|
|
3665
|
+
// and user is not on a public route, invoke the onTenantMismatch callback.
|
|
3666
|
+
React.useEffect(() => {
|
|
3667
|
+
if (!onTenantMismatch)
|
|
3668
|
+
return;
|
|
3669
|
+
const interval = setInterval(() => {
|
|
3670
|
+
if (requestedTenant &&
|
|
3671
|
+
currentTenant &&
|
|
3672
|
+
requestedTenant !== currentTenant &&
|
|
3673
|
+
!userIsAccessingPublicRoute) {
|
|
3674
|
+
console.log("[TenantProvider] Tenant mismatch detected", {
|
|
3675
|
+
requestedTenant,
|
|
3676
|
+
currentTenant,
|
|
3677
|
+
});
|
|
3678
|
+
onTenantMismatch();
|
|
3679
|
+
}
|
|
3680
|
+
}, 2000);
|
|
3681
|
+
return () => clearInterval(interval);
|
|
3682
|
+
}, [
|
|
3683
|
+
requestedTenant,
|
|
3684
|
+
currentTenant,
|
|
3685
|
+
userIsAccessingPublicRoute,
|
|
3686
|
+
onTenantMismatch,
|
|
3687
|
+
]);
|
|
3657
3688
|
// Show fallback component during tenant determination
|
|
3658
3689
|
if (isLoading) {
|
|
3659
3690
|
return fallback;
|