@djangocfg/api 2.1.604 → 2.1.606

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/auth.mjs CHANGED
@@ -4380,6 +4380,30 @@ var useDeleteAccount = /* @__PURE__ */ __name(() => {
4380
4380
  };
4381
4381
  }, "useDeleteAccount");
4382
4382
 
4383
+ // src/auth/hooks/legacyStorage.ts
4384
+ var LEGACY_TOKEN_KEYS = [
4385
+ "cfg.auth.access_token",
4386
+ "cfg.auth.refresh_token",
4387
+ "auth_token",
4388
+ "refresh_token",
4389
+ "access_token"
4390
+ ];
4391
+ function purgeLegacyTokenStorage() {
4392
+ const removed = [];
4393
+ try {
4394
+ if (typeof window === "undefined") return removed;
4395
+ for (const key of LEGACY_TOKEN_KEYS) {
4396
+ if (window.localStorage.getItem(key) !== null) {
4397
+ window.localStorage.removeItem(key);
4398
+ removed.push(key);
4399
+ }
4400
+ }
4401
+ } catch {
4402
+ }
4403
+ return removed;
4404
+ }
4405
+ __name(purgeLegacyTokenStorage, "purgeLegacyTokenStorage");
4406
+
4383
4407
  // src/auth/context/AccountsContext.tsx
4384
4408
  import {
4385
4409
  createContext,
@@ -4752,6 +4776,10 @@ __name(hasApiOrigin, "hasApiOrigin");
4752
4776
  var AccountsContext = createContext(void 0);
4753
4777
  function AccountsProvider({ children }) {
4754
4778
  const [profile, setProfile] = useState10(() => {
4779
+ if (!auth.isAuthenticated()) {
4780
+ clearProfileCache();
4781
+ return void 0;
4782
+ }
4755
4783
  const cached = getCachedProfile();
4756
4784
  return cached || void 0;
4757
4785
  });
@@ -4952,6 +4980,10 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
4952
4980
  authLogger.warn("Dead session in storage \u2014 clearing");
4953
4981
  auth.clearSession();
4954
4982
  clearProfileCache();
4983
+ } else if (!hasTokens && !auth.isAuthenticated()) {
4984
+ clearProfileCache();
4985
+ purgeLegacyTokenStorage();
4986
+ if (accountsRef.current.profile) accountsRef.current.logout();
4955
4987
  }
4956
4988
  setProfileSettled(true);
4957
4989
  return;