@iblai/web-utils 1.10.2 → 1.10.4
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.esm.js +15 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +15 -14
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9389,10 +9389,11 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
9389
9389
|
var _a;
|
|
9390
9390
|
try {
|
|
9391
9391
|
setIsAuthenticating(true);
|
|
9392
|
-
|
|
9392
|
+
const authToken = await (storageService === null || storageService === void 0 ? void 0 : storageService.getItem(LOCAL_STORAGE_KEYS.AUTH_TOKEN));
|
|
9393
|
+
if (authToken && !hasNonExpiredAuthToken()) {
|
|
9393
9394
|
const reason = "Auth token expired";
|
|
9394
9395
|
onAuthFailure === null || onAuthFailure === void 0 ? void 0 : onAuthFailure(reason);
|
|
9395
|
-
console.log("[auth-redirect] Auth token has expired"
|
|
9396
|
+
console.log("[auth-redirect] Auth token has expired");
|
|
9396
9397
|
safeRedirectToAuthSpa(undefined, undefined, true);
|
|
9397
9398
|
return;
|
|
9398
9399
|
}
|
|
@@ -9800,28 +9801,28 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
|
|
|
9800
9801
|
return;
|
|
9801
9802
|
}
|
|
9802
9803
|
}
|
|
9803
|
-
// If there is a
|
|
9804
|
+
// If there is a effectiveRequestedTenant and user doesn't belong to that tenant,
|
|
9804
9805
|
// redirect to auth to re-authenticate. Use a sessionStorage guard to prevent
|
|
9805
9806
|
// an infinite loop: if we already tried once this session and the user still
|
|
9806
9807
|
// doesn't belong after re-auth, surface the failure instead of looping.
|
|
9807
|
-
if (
|
|
9808
|
-
if (!(enhancedTenants === null || enhancedTenants === void 0 ? void 0 : enhancedTenants.find((tenant) => tenant.key ===
|
|
9809
|
-
const guardKey = `tenant_access_attempt_${
|
|
9808
|
+
if (effectiveRequestedTenant) {
|
|
9809
|
+
if (!(enhancedTenants === null || enhancedTenants === void 0 ? void 0 : enhancedTenants.find((tenant) => tenant.key === effectiveRequestedTenant))) {
|
|
9810
|
+
const guardKey = `tenant_access_attempt_${effectiveRequestedTenant}`;
|
|
9810
9811
|
if (isWeb() && sessionStorage.getItem(guardKey)) {
|
|
9811
9812
|
sessionStorage.removeItem(guardKey);
|
|
9812
|
-
console.warn(`[TenantProvider] User still does not belong to
|
|
9813
|
-
onAuthFailure === null || onAuthFailure === void 0 ? void 0 : onAuthFailure(`You do not have access to this platform (${
|
|
9813
|
+
console.warn(`[TenantProvider] User still does not belong to tenant after re-auth: ${effectiveRequestedTenant}`);
|
|
9814
|
+
onAuthFailure === null || onAuthFailure === void 0 ? void 0 : onAuthFailure(`You do not have access to this platform (${effectiveRequestedTenant}). Please contact your administrator.`);
|
|
9814
9815
|
return;
|
|
9815
9816
|
}
|
|
9816
9817
|
let joined = false;
|
|
9817
|
-
joined = await joinAndActivateTenant(
|
|
9818
|
-
platform_key:
|
|
9819
|
-
platform_name:
|
|
9818
|
+
joined = await joinAndActivateTenant(effectiveRequestedTenant, {
|
|
9819
|
+
platform_key: effectiveRequestedTenant,
|
|
9820
|
+
platform_name: effectiveRequestedTenant,
|
|
9820
9821
|
}, {
|
|
9821
|
-
key:
|
|
9822
|
+
key: effectiveRequestedTenant,
|
|
9822
9823
|
is_admin: false,
|
|
9823
|
-
org:
|
|
9824
|
-
platform_name:
|
|
9824
|
+
org: effectiveRequestedTenant,
|
|
9825
|
+
platform_name: effectiveRequestedTenant,
|
|
9825
9826
|
}, { handleVisitingTenant: false });
|
|
9826
9827
|
if (isWeb()) {
|
|
9827
9828
|
if (!joined) {
|