@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.cjs
CHANGED
|
@@ -4698,7 +4698,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4698
4698
|
};
|
|
4699
4699
|
}
|
|
4700
4700
|
}, [clearAuthState, accounts]);
|
|
4701
|
-
const logout = (0, import_react4.useCallback)(async () => {
|
|
4701
|
+
const logout = (0, import_react4.useCallback)(async (options) => {
|
|
4702
4702
|
const performLogout = /* @__PURE__ */ __name(() => {
|
|
4703
4703
|
Analytics.event("auth_logout" /* AUTH_LOGOUT */, {
|
|
4704
4704
|
category: "auth" /* AUTH */
|
|
@@ -4709,6 +4709,10 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4709
4709
|
const authCallbackUrl = config?.routes?.defaultAuthCallback || defaultRoutes.defaultAuthCallback;
|
|
4710
4710
|
router.hardReplace(authCallbackUrl);
|
|
4711
4711
|
}, "performLogout");
|
|
4712
|
+
if (options?.skipConfirm) {
|
|
4713
|
+
performLogout();
|
|
4714
|
+
return;
|
|
4715
|
+
}
|
|
4712
4716
|
if (configRef.current?.onConfirm) {
|
|
4713
4717
|
const { confirmed } = await configRef.current.onConfirm({
|
|
4714
4718
|
title: "Logout",
|
|
@@ -4730,6 +4734,20 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4730
4734
|
const isAdminUser = (0, import_react4.useMemo)(() => {
|
|
4731
4735
|
return Boolean(user?.is_staff || user?.is_superuser);
|
|
4732
4736
|
}, [user]);
|
|
4737
|
+
const updateProfile = (0, import_react4.useCallback)(
|
|
4738
|
+
async (data) => {
|
|
4739
|
+
const result = await accounts.partialUpdateProfile(data);
|
|
4740
|
+
return result;
|
|
4741
|
+
},
|
|
4742
|
+
[accounts]
|
|
4743
|
+
);
|
|
4744
|
+
const uploadAvatar = (0, import_react4.useCallback)(
|
|
4745
|
+
async (avatar) => {
|
|
4746
|
+
const result = await accounts.uploadAvatar(avatar);
|
|
4747
|
+
return result;
|
|
4748
|
+
},
|
|
4749
|
+
[accounts]
|
|
4750
|
+
);
|
|
4733
4751
|
const value = (0, import_react4.useMemo)(
|
|
4734
4752
|
() => ({
|
|
4735
4753
|
user,
|
|
@@ -4755,7 +4773,10 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4755
4773
|
saveRedirectUrl: redirectManager.setRedirect,
|
|
4756
4774
|
getRedirectUrl: redirectManager.getFinalRedirectUrl,
|
|
4757
4775
|
clearRedirectUrl: redirectManager.clearRedirect,
|
|
4758
|
-
hasRedirectUrl: redirectManager.hasRedirect
|
|
4776
|
+
hasRedirectUrl: redirectManager.hasRedirect,
|
|
4777
|
+
// Profile management
|
|
4778
|
+
updateProfile,
|
|
4779
|
+
uploadAvatar
|
|
4759
4780
|
}),
|
|
4760
4781
|
[
|
|
4761
4782
|
user,
|
|
@@ -4773,7 +4794,9 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4773
4794
|
verifyOTP,
|
|
4774
4795
|
refreshToken,
|
|
4775
4796
|
logout,
|
|
4776
|
-
redirectManager
|
|
4797
|
+
redirectManager,
|
|
4798
|
+
updateProfile,
|
|
4799
|
+
uploadAvatar
|
|
4777
4800
|
]
|
|
4778
4801
|
);
|
|
4779
4802
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AuthContext.Provider, { value, children });
|
|
@@ -4818,7 +4841,7 @@ var defaultAuthState = {
|
|
|
4818
4841
|
authLogger.warn("useAuth: refreshToken called outside AuthProvider");
|
|
4819
4842
|
return { success: false, message: "AuthProvider not available" };
|
|
4820
4843
|
}, "refreshToken"),
|
|
4821
|
-
logout: /* @__PURE__ */ __name(async () => {
|
|
4844
|
+
logout: /* @__PURE__ */ __name(async (_options) => {
|
|
4822
4845
|
authLogger.warn("useAuth: logout called outside AuthProvider");
|
|
4823
4846
|
}, "logout"),
|
|
4824
4847
|
saveRedirectUrl: /* @__PURE__ */ __name(() => {
|
|
@@ -4826,7 +4849,15 @@ var defaultAuthState = {
|
|
|
4826
4849
|
getRedirectUrl: /* @__PURE__ */ __name(() => null, "getRedirectUrl"),
|
|
4827
4850
|
clearRedirectUrl: /* @__PURE__ */ __name(() => {
|
|
4828
4851
|
}, "clearRedirectUrl"),
|
|
4829
|
-
hasRedirectUrl: /* @__PURE__ */ __name(() => false, "hasRedirectUrl")
|
|
4852
|
+
hasRedirectUrl: /* @__PURE__ */ __name(() => false, "hasRedirectUrl"),
|
|
4853
|
+
updateProfile: /* @__PURE__ */ __name(async () => {
|
|
4854
|
+
authLogger.warn("useAuth: updateProfile called outside AuthProvider");
|
|
4855
|
+
return {};
|
|
4856
|
+
}, "updateProfile"),
|
|
4857
|
+
uploadAvatar: /* @__PURE__ */ __name(async () => {
|
|
4858
|
+
authLogger.warn("useAuth: uploadAvatar called outside AuthProvider");
|
|
4859
|
+
return {};
|
|
4860
|
+
}, "uploadAvatar")
|
|
4830
4861
|
};
|
|
4831
4862
|
var useAuth = /* @__PURE__ */ __name(() => {
|
|
4832
4863
|
const context = (0, import_react4.useContext)(AuthContext);
|