@@ -8,6 +8,8 @@ import { openApp, recordToSearchStr } from "../../util/appUtils";
8
8
import { trans } from "i18n" ;
9
9
import { logoutAction } from "redux/reduxActions/userActions" ;
10
10
import StoreRegistry from "@lowcoder-ee/redux/store/storeRegistry" ;
11
+ import UserApi from "@lowcoder-ee/api/userApi" ;
12
+ import { messageInstance } from "components/GlobalInstances" ;
11
13
12
14
const UtilsCompBase = simpleMultiComp ( { } ) ;
13
15
export let UtilsComp = withExposingConfigs ( UtilsCompBase , [ ] ) ;
@@ -121,4 +123,33 @@ UtilsComp = withMethodExposing(UtilsComp, [
121
123
) ;
122
124
} ,
123
125
} ,
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
+ }
124
155
] ) ;
0 commit comments