@iblai/web-utils 1.2.11 → 1.2.13

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
@@ -750,7 +750,7 @@ const LOCAL_STORAGE_KEYS = {
750
750
  USER_DATA: "userData",
751
751
  USER_TENANTS: "tenants",
752
752
  EDX_TOKEN_KEY: "edx_jwt_token",
753
- DM_TOKEN_KEY: "dm_token_key",
753
+ DM_TOKEN_KEY: "dm_token",
754
754
  DM_TOKEN_EXPIRES: "dm_token_expires",
755
755
  };
756
756
  const TOOLS = {
@@ -3012,11 +3012,19 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
3012
3012
  // Check JWT token expiry and force logout for protected routes
3013
3013
  if (isProtectedRoute && storageService) {
3014
3014
  const dmTokenInLocalStorage = await storageService.getItem(LOCAL_STORAGE_KEYS.DM_TOKEN_KEY);
3015
+ console.log('[auth-redirect] local storage keys ', LOCAL_STORAGE_KEYS);
3015
3016
  const dmTokenExpired = await isDmTokenExpired(storageService);
3016
3017
  if (!dmTokenInLocalStorage || dmTokenExpired) {
3017
- console.log("[auth-redirect] DM token has expired, forcing logout");
3018
+ if (!!dmTokenInLocalStorage) {
3019
+ console.log("[auth-redirect] DM token doesn't exists");
3020
+ }
3021
+ else {
3022
+ console.log("[auth-redirect] DM token doesn't exists, forcing logout");
3023
+ }
3018
3024
  // Clear all auth-related storage keys
3019
- clearAuthCookies();
3025
+ if (!!dmTokenInLocalStorage) {
3026
+ clearAuthCookies();
3027
+ }
3020
3028
  const reason = "DM token expired";
3021
3029
  onAuthFailure === null || onAuthFailure === void 0 ? void 0 : onAuthFailure(reason);
3022
3030
  safeRedirectToAuthSpa(undefined, undefined, !!dmTokenInLocalStorage); // with no dm token at all in storage, don't force logout