@djangocfg/api 2.1.100 → 2.1.102
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 +36 -5
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +9 -1
- package/dist/auth.d.ts +9 -1
- package/dist/auth.mjs +36 -5
- package/dist/auth.mjs.map +1 -1
- package/package.json +3 -3
- package/src/auth/context/AuthContext.tsx +39 -2
- package/src/auth/context/types.ts +5 -1
package/dist/auth.d.cts
CHANGED
|
@@ -295,11 +295,19 @@ interface AuthContextType {
|
|
|
295
295
|
success: boolean;
|
|
296
296
|
message: string;
|
|
297
297
|
}>;
|
|
298
|
-
logout: (
|
|
298
|
+
logout: (options?: {
|
|
299
|
+
skipConfirm?: boolean;
|
|
300
|
+
}) => Promise<void>;
|
|
299
301
|
saveRedirectUrl: (url: string) => void;
|
|
300
302
|
getRedirectUrl: () => string;
|
|
301
303
|
clearRedirectUrl: () => void;
|
|
302
304
|
hasRedirectUrl: () => boolean;
|
|
305
|
+
updateProfile: (data: {
|
|
306
|
+
first_name?: string;
|
|
307
|
+
last_name?: string;
|
|
308
|
+
username?: string;
|
|
309
|
+
}) => Promise<UserProfile>;
|
|
310
|
+
uploadAvatar: (avatar: File | Blob) => Promise<UserProfile>;
|
|
303
311
|
}
|
|
304
312
|
interface AuthProviderProps {
|
|
305
313
|
children: React$1.ReactNode;
|
package/dist/auth.d.ts
CHANGED
|
@@ -295,11 +295,19 @@ interface AuthContextType {
|
|
|
295
295
|
success: boolean;
|
|
296
296
|
message: string;
|
|
297
297
|
}>;
|
|
298
|
-
logout: (
|
|
298
|
+
logout: (options?: {
|
|
299
|
+
skipConfirm?: boolean;
|
|
300
|
+
}) => Promise<void>;
|
|
299
301
|
saveRedirectUrl: (url: string) => void;
|
|
300
302
|
getRedirectUrl: () => string;
|
|
301
303
|
clearRedirectUrl: () => void;
|
|
302
304
|
hasRedirectUrl: () => boolean;
|
|
305
|
+
updateProfile: (data: {
|
|
306
|
+
first_name?: string;
|
|
307
|
+
last_name?: string;
|
|
308
|
+
username?: string;
|
|
309
|
+
}) => Promise<UserProfile>;
|
|
310
|
+
uploadAvatar: (avatar: File | Blob) => Promise<UserProfile>;
|
|
303
311
|
}
|
|
304
312
|
interface AuthProviderProps {
|
|
305
313
|
children: React$1.ReactNode;
|
package/dist/auth.mjs
CHANGED
|
@@ -4649,7 +4649,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4649
4649
|
};
|
|
4650
4650
|
}
|
|
4651
4651
|
}, [clearAuthState, accounts]);
|
|
4652
|
-
const logout = useCallback3(async () => {
|
|
4652
|
+
const logout = useCallback3(async (options) => {
|
|
4653
4653
|
const performLogout = /* @__PURE__ */ __name(() => {
|
|
4654
4654
|
Analytics.event("auth_logout" /* AUTH_LOGOUT */, {
|
|
4655
4655
|
category: "auth" /* AUTH */
|
|
@@ -4660,6 +4660,10 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4660
4660
|
const authCallbackUrl = config?.routes?.defaultAuthCallback || defaultRoutes.defaultAuthCallback;
|
|
4661
4661
|
router.hardReplace(authCallbackUrl);
|
|
4662
4662
|
}, "performLogout");
|
|
4663
|
+
if (options?.skipConfirm) {
|
|
4664
|
+
performLogout();
|
|
4665
|
+
return;
|
|
4666
|
+
}
|
|
4663
4667
|
if (configRef.current?.onConfirm) {
|
|
4664
4668
|
const { confirmed } = await configRef.current.onConfirm({
|
|
4665
4669
|
title: "Logout",
|
|
@@ -4681,6 +4685,20 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4681
4685
|
const isAdminUser = useMemo(() => {
|
|
4682
4686
|
return Boolean(user?.is_staff || user?.is_superuser);
|
|
4683
4687
|
}, [user]);
|
|
4688
|
+
const updateProfile = useCallback3(
|
|
4689
|
+
async (data) => {
|
|
4690
|
+
const result = await accounts.partialUpdateProfile(data);
|
|
4691
|
+
return result;
|
|
4692
|
+
},
|
|
4693
|
+
[accounts]
|
|
4694
|
+
);
|
|
4695
|
+
const uploadAvatar = useCallback3(
|
|
4696
|
+
async (avatar) => {
|
|
4697
|
+
const result = await accounts.uploadAvatar(avatar);
|
|
4698
|
+
return result;
|
|
4699
|
+
},
|
|
4700
|
+
[accounts]
|
|
4701
|
+
);
|
|
4684
4702
|
const value = useMemo(
|
|
4685
4703
|
() => ({
|
|
4686
4704
|
user,
|
|
@@ -4706,7 +4724,10 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4706
4724
|
saveRedirectUrl: redirectManager.setRedirect,
|
|
4707
4725
|
getRedirectUrl: redirectManager.getFinalRedirectUrl,
|
|
4708
4726
|
clearRedirectUrl: redirectManager.clearRedirect,
|
|
4709
|
-
hasRedirectUrl: redirectManager.hasRedirect
|
|
4727
|
+
hasRedirectUrl: redirectManager.hasRedirect,
|
|
4728
|
+
// Profile management
|
|
4729
|
+
updateProfile,
|
|
4730
|
+
uploadAvatar
|
|
4710
4731
|
}),
|
|
4711
4732
|
[
|
|
4712
4733
|
user,
|
|
@@ -4724,7 +4745,9 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4724
4745
|
verifyOTP,
|
|
4725
4746
|
refreshToken,
|
|
4726
4747
|
logout,
|
|
4727
|
-
redirectManager
|
|
4748
|
+
redirectManager,
|
|
4749
|
+
updateProfile,
|
|
4750
|
+
uploadAvatar
|
|
4728
4751
|
]
|
|
4729
4752
|
);
|
|
4730
4753
|
return /* @__PURE__ */ jsx2(AuthContext.Provider, { value, children });
|
|
@@ -4769,7 +4792,7 @@ var defaultAuthState = {
|
|
|
4769
4792
|
authLogger.warn("useAuth: refreshToken called outside AuthProvider");
|
|
4770
4793
|
return { success: false, message: "AuthProvider not available" };
|
|
4771
4794
|
}, "refreshToken"),
|
|
4772
|
-
logout: /* @__PURE__ */ __name(async () => {
|
|
4795
|
+
logout: /* @__PURE__ */ __name(async (_options) => {
|
|
4773
4796
|
authLogger.warn("useAuth: logout called outside AuthProvider");
|
|
4774
4797
|
}, "logout"),
|
|
4775
4798
|
saveRedirectUrl: /* @__PURE__ */ __name(() => {
|
|
@@ -4777,7 +4800,15 @@ var defaultAuthState = {
|
|
|
4777
4800
|
getRedirectUrl: /* @__PURE__ */ __name(() => null, "getRedirectUrl"),
|
|
4778
4801
|
clearRedirectUrl: /* @__PURE__ */ __name(() => {
|
|
4779
4802
|
}, "clearRedirectUrl"),
|
|
4780
|
-
hasRedirectUrl: /* @__PURE__ */ __name(() => false, "hasRedirectUrl")
|
|
4803
|
+
hasRedirectUrl: /* @__PURE__ */ __name(() => false, "hasRedirectUrl"),
|
|
4804
|
+
updateProfile: /* @__PURE__ */ __name(async () => {
|
|
4805
|
+
authLogger.warn("useAuth: updateProfile called outside AuthProvider");
|
|
4806
|
+
return {};
|
|
4807
|
+
}, "updateProfile"),
|
|
4808
|
+
uploadAvatar: /* @__PURE__ */ __name(async () => {
|
|
4809
|
+
authLogger.warn("useAuth: uploadAvatar called outside AuthProvider");
|
|
4810
|
+
return {};
|
|
4811
|
+
}, "uploadAvatar")
|
|
4781
4812
|
};
|
|
4782
4813
|
var useAuth = /* @__PURE__ */ __name(() => {
|
|
4783
4814
|
const context = useContext2(AuthContext);
|