@iblai/web-utils 1.2.2 → 1.2.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.js CHANGED
@@ -3370,25 +3370,34 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
3370
3370
  if (isWeb() && sessionStorage.getItem(guardKey)) {
3371
3371
  sessionStorage.removeItem(guardKey);
3372
3372
  console.warn(`[TenantProvider] User still does not belong to custom domain tenant after re-auth: ${customDomainPlatformKey}`);
3373
- const joined = await joinAndActivateTenant(customDomainPlatformKey, {
3374
- platform_key: customDomainPlatformKey,
3375
- platform_name: customDomainPlatformKey,
3376
- }, {
3377
- key: customDomainPlatformKey,
3378
- is_admin: false,
3379
- org: customDomainPlatformKey,
3380
- platform_name: customDomainPlatformKey,
3381
- }, { handleVisitingTenant: false });
3382
- if (!joined) {
3383
- onAuthFailure === null || onAuthFailure === void 0 ? void 0 : onAuthFailure(`You do not have access to this platform (${customDomainPlatformKey}). Please contact your administrator.`);
3384
- }
3373
+ onAuthFailure === null || onAuthFailure === void 0 ? void 0 : onAuthFailure(`You do not have access to this platform (${customDomainPlatformKey}). Please contact your administrator.`);
3385
3374
  return;
3386
3375
  }
3376
+ let joined = false;
3377
+ joined = await joinAndActivateTenant(customDomainPlatformKey, {
3378
+ platform_key: customDomainPlatformKey,
3379
+ platform_name: customDomainPlatformKey,
3380
+ }, {
3381
+ key: customDomainPlatformKey,
3382
+ is_admin: false,
3383
+ org: customDomainPlatformKey,
3384
+ platform_name: customDomainPlatformKey,
3385
+ }, { handleVisitingTenant: false });
3387
3386
  if (isWeb()) {
3388
- sessionStorage.setItem(guardKey, "1");
3387
+ if (!joined) {
3388
+ sessionStorage.setItem(guardKey, "1");
3389
+ }
3390
+ else {
3391
+ const { data: tenants } = await fetchUserTenants();
3392
+ console.log("[determineWhichTenantToUse] tenants after joining are ", tenants);
3393
+ // Enhance tenants with platform metadata
3394
+ enhancedTenants = await enhanceTenants(tenants);
3395
+ }
3396
+ }
3397
+ if (!joined) {
3398
+ redirectToAuthSpa === null || redirectToAuthSpa === void 0 ? void 0 : redirectToAuthSpa(undefined, undefined, true);
3399
+ return;
3389
3400
  }
3390
- redirectToAuthSpa === null || redirectToAuthSpa === void 0 ? void 0 : redirectToAuthSpa(undefined, undefined, true);
3391
- return;
3392
3401
  }
3393
3402
  }
3394
3403
  saveUserTenants(enhancedTenants);