@djangocfg/api 2.1.100 → 2.1.101
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 +30 -3
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +6 -0
- package/dist/auth.d.ts +6 -0
- package/dist/auth.mjs +30 -3
- package/dist/auth.mjs.map +1 -1
- package/package.json +3 -3
- package/src/auth/context/AuthContext.tsx +31 -0
- package/src/auth/context/types.ts +4 -0
package/dist/auth.cjs
CHANGED
|
@@ -4730,6 +4730,20 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4730
4730
|
const isAdminUser = (0, import_react4.useMemo)(() => {
|
|
4731
4731
|
return Boolean(user?.is_staff || user?.is_superuser);
|
|
4732
4732
|
}, [user]);
|
|
4733
|
+
const updateProfile = (0, import_react4.useCallback)(
|
|
4734
|
+
async (data) => {
|
|
4735
|
+
const result = await accounts.partialUpdateProfile(data);
|
|
4736
|
+
return result;
|
|
4737
|
+
},
|
|
4738
|
+
[accounts]
|
|
4739
|
+
);
|
|
4740
|
+
const uploadAvatar = (0, import_react4.useCallback)(
|
|
4741
|
+
async (avatar) => {
|
|
4742
|
+
const result = await accounts.uploadAvatar(avatar);
|
|
4743
|
+
return result;
|
|
4744
|
+
},
|
|
4745
|
+
[accounts]
|
|
4746
|
+
);
|
|
4733
4747
|
const value = (0, import_react4.useMemo)(
|
|
4734
4748
|
() => ({
|
|
4735
4749
|
user,
|
|
@@ -4755,7 +4769,10 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4755
4769
|
saveRedirectUrl: redirectManager.setRedirect,
|
|
4756
4770
|
getRedirectUrl: redirectManager.getFinalRedirectUrl,
|
|
4757
4771
|
clearRedirectUrl: redirectManager.clearRedirect,
|
|
4758
|
-
hasRedirectUrl: redirectManager.hasRedirect
|
|
4772
|
+
hasRedirectUrl: redirectManager.hasRedirect,
|
|
4773
|
+
// Profile management
|
|
4774
|
+
updateProfile,
|
|
4775
|
+
uploadAvatar
|
|
4759
4776
|
}),
|
|
4760
4777
|
[
|
|
4761
4778
|
user,
|
|
@@ -4773,7 +4790,9 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4773
4790
|
verifyOTP,
|
|
4774
4791
|
refreshToken,
|
|
4775
4792
|
logout,
|
|
4776
|
-
redirectManager
|
|
4793
|
+
redirectManager,
|
|
4794
|
+
updateProfile,
|
|
4795
|
+
uploadAvatar
|
|
4777
4796
|
]
|
|
4778
4797
|
);
|
|
4779
4798
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AuthContext.Provider, { value, children });
|
|
@@ -4826,7 +4845,15 @@ var defaultAuthState = {
|
|
|
4826
4845
|
getRedirectUrl: /* @__PURE__ */ __name(() => null, "getRedirectUrl"),
|
|
4827
4846
|
clearRedirectUrl: /* @__PURE__ */ __name(() => {
|
|
4828
4847
|
}, "clearRedirectUrl"),
|
|
4829
|
-
hasRedirectUrl: /* @__PURE__ */ __name(() => false, "hasRedirectUrl")
|
|
4848
|
+
hasRedirectUrl: /* @__PURE__ */ __name(() => false, "hasRedirectUrl"),
|
|
4849
|
+
updateProfile: /* @__PURE__ */ __name(async () => {
|
|
4850
|
+
authLogger.warn("useAuth: updateProfile called outside AuthProvider");
|
|
4851
|
+
return {};
|
|
4852
|
+
}, "updateProfile"),
|
|
4853
|
+
uploadAvatar: /* @__PURE__ */ __name(async () => {
|
|
4854
|
+
authLogger.warn("useAuth: uploadAvatar called outside AuthProvider");
|
|
4855
|
+
return {};
|
|
4856
|
+
}, "uploadAvatar")
|
|
4830
4857
|
};
|
|
4831
4858
|
var useAuth = /* @__PURE__ */ __name(() => {
|
|
4832
4859
|
const context = (0, import_react4.useContext)(AuthContext);
|