Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b4f61eb

Browse files
expose resetPassword function with utils
1 parent 67df145 commit b4f61eb

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

‎client/packages/lowcoder/src/comps/hooks/utilsComp.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { openApp, recordToSearchStr } from "../../util/appUtils";
88
import { trans } from "i18n";
99
import { logoutAction } from "redux/reduxActions/userActions";
1010
import StoreRegistry from "@lowcoder-ee/redux/store/storeRegistry";
11+
import UserApi from "@lowcoder-ee/api/userApi";
12+
import { messageInstance } from "components/GlobalInstances";
1113

1214
const UtilsCompBase = simpleMultiComp({});
1315
export let UtilsComp = withExposingConfigs(UtilsCompBase, []);
@@ -121,4 +123,33 @@ UtilsComp = withMethodExposing(UtilsComp, [
121123
);
122124
},
123125
},
126+
{
127+
method: {
128+
name: "resetPassword",
129+
description: trans("utilsComp.resetPassword"),
130+
params: [
131+
{ name: "oldPassword", type: "string" },
132+
{ name: "newPassword", type: "string" },
133+
],
134+
},
135+
execute: async (comp, params) => {
136+
const oldPassword = params?.[0];
137+
const newPassword = params?.[1];
138+
try {
139+
if (Boolean(oldPassword) && Boolean(newPassword)) {
140+
const response = await UserApi.updatePassword({
141+
oldPassword: oldPassword as string,
142+
newPassword: newPassword as string,
143+
});
144+
if (!response.data.success) {
145+
throw (new Error(response.data.message));
146+
}
147+
} else {
148+
throw(new Error('Reset password requires both old and new passwords'))
149+
}
150+
} catch(e: any) {
151+
messageInstance.error(e.message)
152+
}
153+
},
154+
}
124155
]);

‎client/packages/lowcoder/src/i18n/locales/en.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2630,6 +2630,7 @@ export const en = {
26302630
"copyToClipboard": "Copy to Clipboard",
26312631
"downloadFile": "Download File",
26322632
"logoutUser" : "Logout User",
2633+
"resetPassword" : "Reset Password",
26332634
},
26342635
"messageComp": {
26352636
"info": "Send a Notification",
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { useSelector } from "react-redux";
2-
import { getCurrentUser } from "redux/selectors/usersSelectors";
2+
import { getCurrentUser,getUser } from "redux/selectors/usersSelectors";
33

44
export function useCurrentUser() {
55
const currentUser = useSelector(getCurrentUser);
6-
return currentUser;
6+
const { hasPassword } = useSelector(getUser);
7+
return {...currentUser, hasPassword};
78
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /