@djangocfg/api 2.1.129 → 2.1.130

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.cjs CHANGED
@@ -6494,20 +6494,18 @@ function AccountsProvider({ children }) {
6494
6494
  const otpRequestMutation = useCreateAccountsOtpRequestCreate();
6495
6495
  const otpVerifyMutation = useCreateAccountsOtpVerifyCreate();
6496
6496
  const tokenRefreshMutation = useCreateAccountsTokenRefreshCreate();
6497
- const refreshProfile = (0, import_react16.useCallback)(async (callerId) => {
6498
- const currentProfile = profileRef.current;
6497
+ const refreshProfile = (0, import_react16.useCallback)(async (options) => {
6498
+ const { callerId, force } = options || {};
6499
6499
  const currentLoading = isLoadingRef.current;
6500
- if (currentProfile && !currentLoading) {
6501
- authLogger.debug(`Profile already loaded, returning cached (caller: ${callerId})`);
6502
- return currentProfile;
6500
+ if (currentLoading) {
6501
+ authLogger.debug(`Profile loading in progress, skipping (caller: ${callerId})`);
6502
+ return profileRef.current;
6503
6503
  }
6504
6504
  setIsLoadingProfile(true);
6505
6505
  isLoadingRef.current = true;
6506
6506
  setProfileError(null);
6507
6507
  try {
6508
- if (callerId) {
6509
- authLogger.debug(`Profile refresh called by: ${callerId}`);
6510
- }
6508
+ authLogger.debug(`Fetching profile from API (caller: ${callerId}, force: ${force})`);
6511
6509
  const result = await getAccountsProfileRetrieve(api);
6512
6510
  setProfile(result);
6513
6511
  profileRef.current = result;
@@ -6523,19 +6521,19 @@ function AccountsProvider({ children }) {
6523
6521
  }
6524
6522
  }, []);
6525
6523
  const updateProfile = /* @__PURE__ */ __name(async (data) => {
6526
- const result = await updateMutation(data, api);
6527
- await refreshProfile("AccountsContext.updateProfile");
6528
- return result;
6524
+ await updateMutation(data, api);
6525
+ const user = await refreshProfile({ callerId: "updateProfile", force: true });
6526
+ return user;
6529
6527
  }, "updateProfile");
6530
6528
  const partialUpdateProfile = /* @__PURE__ */ __name(async (data) => {
6531
- const result = await partialUpdateMutation(data, api);
6532
- await refreshProfile("AccountsContext.partialUpdateProfile");
6533
- return result;
6529
+ await partialUpdateMutation(data, api);
6530
+ const user = await refreshProfile({ callerId: "partialUpdateProfile", force: true });
6531
+ return user;
6534
6532
  }, "partialUpdateProfile");
6535
6533
  const uploadAvatar = /* @__PURE__ */ __name(async (avatar) => {
6536
- const result = await avatarMutation({ avatar }, api);
6537
- await refreshProfile("AccountsContext.uploadAvatar");
6538
- return result;
6534
+ await avatarMutation({ avatar }, api);
6535
+ const user = await refreshProfile({ callerId: "uploadAvatar", force: true });
6536
+ return user;
6539
6537
  }, "uploadAvatar");
6540
6538
  const requestOTP = /* @__PURE__ */ __name(async (data) => {
6541
6539
  const result = await otpRequestMutation(data, api);
@@ -6549,7 +6547,7 @@ function AccountsProvider({ children }) {
6549
6547
  }
6550
6548
  if (result.access && result.refresh) {
6551
6549
  api.setToken(result.access, result.refresh);
6552
- await refreshProfile("AccountsContext.verifyOTP");
6550
+ await refreshProfile({ callerId: "verifyOTP", force: true });
6553
6551
  }
6554
6552
  return result;
6555
6553
  }, "verifyOTP");
@@ -6682,7 +6680,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6682
6680
  setInitialized(true);
6683
6681
  return;
6684
6682
  }
6685
- const refreshedProfile = await accounts.refreshProfile(finalCallerId);
6683
+ const refreshedProfile = await accounts.refreshProfile({ callerId: finalCallerId });
6686
6684
  if (refreshedProfile) {
6687
6685
  authLogger.info("Profile loaded successfully:", refreshedProfile.id);
6688
6686
  } else {