@djangocfg/api 2.1.129 → 2.1.131
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 +17 -19
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +4 -1
- package/dist/auth.d.ts +4 -1
- package/dist/auth.mjs +17 -19
- package/dist/auth.mjs.map +1 -1
- package/package.json +2 -2
- package/src/auth/context/AccountsContext.tsx +23 -28
- package/src/auth/context/AuthContext.tsx +2 -2
package/dist/auth.d.cts
CHANGED
|
@@ -321,7 +321,10 @@ interface AccountsContextValue {
|
|
|
321
321
|
updateProfile: (data: UserProfileUpdateRequest) => Promise<User>;
|
|
322
322
|
partialUpdateProfile: (data: PatchedUserProfileUpdateRequest) => Promise<User>;
|
|
323
323
|
uploadAvatar: (avatar: File | Blob) => Promise<User>;
|
|
324
|
-
refreshProfile: (
|
|
324
|
+
refreshProfile: (options?: {
|
|
325
|
+
callerId?: string;
|
|
326
|
+
force?: boolean;
|
|
327
|
+
}) => Promise<User | undefined>;
|
|
325
328
|
requestOTP: (data: OTPRequestRequest) => Promise<OTPRequestResponse>;
|
|
326
329
|
verifyOTP: (data: OTPVerifyRequest) => Promise<OTPVerifyResponse>;
|
|
327
330
|
refreshToken: (refresh: string) => Promise<TokenRefresh>;
|
package/dist/auth.d.ts
CHANGED
|
@@ -321,7 +321,10 @@ interface AccountsContextValue {
|
|
|
321
321
|
updateProfile: (data: UserProfileUpdateRequest) => Promise<User>;
|
|
322
322
|
partialUpdateProfile: (data: PatchedUserProfileUpdateRequest) => Promise<User>;
|
|
323
323
|
uploadAvatar: (avatar: File | Blob) => Promise<User>;
|
|
324
|
-
refreshProfile: (
|
|
324
|
+
refreshProfile: (options?: {
|
|
325
|
+
callerId?: string;
|
|
326
|
+
force?: boolean;
|
|
327
|
+
}) => Promise<User | undefined>;
|
|
325
328
|
requestOTP: (data: OTPRequestRequest) => Promise<OTPRequestResponse>;
|
|
326
329
|
verifyOTP: (data: OTPVerifyRequest) => Promise<OTPVerifyResponse>;
|
|
327
330
|
refreshToken: (refresh: string) => Promise<TokenRefresh>;
|
package/dist/auth.mjs
CHANGED
|
@@ -6443,20 +6443,18 @@ function AccountsProvider({ children }) {
|
|
|
6443
6443
|
const otpRequestMutation = useCreateAccountsOtpRequestCreate();
|
|
6444
6444
|
const otpVerifyMutation = useCreateAccountsOtpVerifyCreate();
|
|
6445
6445
|
const tokenRefreshMutation = useCreateAccountsTokenRefreshCreate();
|
|
6446
|
-
const refreshProfile = useCallback11(async (
|
|
6447
|
-
const
|
|
6446
|
+
const refreshProfile = useCallback11(async (options) => {
|
|
6447
|
+
const { callerId, force } = options || {};
|
|
6448
6448
|
const currentLoading = isLoadingRef.current;
|
|
6449
|
-
if (
|
|
6450
|
-
authLogger.debug(`Profile
|
|
6451
|
-
return
|
|
6449
|
+
if (currentLoading) {
|
|
6450
|
+
authLogger.debug(`Profile loading in progress, skipping (caller: ${callerId})`);
|
|
6451
|
+
return profileRef.current;
|
|
6452
6452
|
}
|
|
6453
6453
|
setIsLoadingProfile(true);
|
|
6454
6454
|
isLoadingRef.current = true;
|
|
6455
6455
|
setProfileError(null);
|
|
6456
6456
|
try {
|
|
6457
|
-
|
|
6458
|
-
authLogger.debug(`Profile refresh called by: ${callerId}`);
|
|
6459
|
-
}
|
|
6457
|
+
authLogger.debug(`Fetching profile from API (caller: ${callerId}, force: ${force})`);
|
|
6460
6458
|
const result = await getAccountsProfileRetrieve(api);
|
|
6461
6459
|
setProfile(result);
|
|
6462
6460
|
profileRef.current = result;
|
|
@@ -6472,19 +6470,19 @@ function AccountsProvider({ children }) {
|
|
|
6472
6470
|
}
|
|
6473
6471
|
}, []);
|
|
6474
6472
|
const updateProfile = /* @__PURE__ */ __name(async (data) => {
|
|
6475
|
-
|
|
6476
|
-
await refreshProfile("
|
|
6477
|
-
return
|
|
6473
|
+
await updateMutation(data, api);
|
|
6474
|
+
const user = await refreshProfile({ callerId: "updateProfile", force: true });
|
|
6475
|
+
return user;
|
|
6478
6476
|
}, "updateProfile");
|
|
6479
6477
|
const partialUpdateProfile = /* @__PURE__ */ __name(async (data) => {
|
|
6480
|
-
|
|
6481
|
-
await refreshProfile("
|
|
6482
|
-
return
|
|
6478
|
+
await partialUpdateMutation(data, api);
|
|
6479
|
+
const user = await refreshProfile({ callerId: "partialUpdateProfile", force: true });
|
|
6480
|
+
return user;
|
|
6483
6481
|
}, "partialUpdateProfile");
|
|
6484
6482
|
const uploadAvatar = /* @__PURE__ */ __name(async (avatar) => {
|
|
6485
|
-
|
|
6486
|
-
await refreshProfile("
|
|
6487
|
-
return
|
|
6483
|
+
await avatarMutation({ avatar }, api);
|
|
6484
|
+
const user = await refreshProfile({ callerId: "uploadAvatar", force: true });
|
|
6485
|
+
return user;
|
|
6488
6486
|
}, "uploadAvatar");
|
|
6489
6487
|
const requestOTP = /* @__PURE__ */ __name(async (data) => {
|
|
6490
6488
|
const result = await otpRequestMutation(data, api);
|
|
@@ -6498,7 +6496,7 @@ function AccountsProvider({ children }) {
|
|
|
6498
6496
|
}
|
|
6499
6497
|
if (result.access && result.refresh) {
|
|
6500
6498
|
api.setToken(result.access, result.refresh);
|
|
6501
|
-
await refreshProfile("
|
|
6499
|
+
await refreshProfile({ callerId: "verifyOTP", force: true });
|
|
6502
6500
|
}
|
|
6503
6501
|
return result;
|
|
6504
6502
|
}, "verifyOTP");
|
|
@@ -6631,7 +6629,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
6631
6629
|
setInitialized(true);
|
|
6632
6630
|
return;
|
|
6633
6631
|
}
|
|
6634
|
-
const refreshedProfile = await accounts.refreshProfile(finalCallerId);
|
|
6632
|
+
const refreshedProfile = await accounts.refreshProfile({ callerId: finalCallerId });
|
|
6635
6633
|
if (refreshedProfile) {
|
|
6636
6634
|
authLogger.info("Profile loaded successfully:", refreshedProfile.id);
|
|
6637
6635
|
} else {
|