|
@@ -196,8 +196,8 @@ public class SysUserController extends BaseController {
|
196
|
196
|
|
197
|
197
|
//验证用户名密码是否正确
|
198
|
198
|
TaChannelProxy taChannelProxy = iTaChannelProxyService.getOne(taChannelProxyQueryWrapper);
|
199
|
|
- String defaultPsw = MD5Utils.md5("abc@123");
|
200
|
|
- if (taChannelProxy == null || !defaultPsw.equals(params.getString("password"))) {
|
|
199
|
+ String defaultPsw = MD5Utils.md5(params.getString("password"));
|
|
200
|
+ if (taChannelProxy == null || !defaultPsw.equals(taChannelProxy.getPassword())) {
|
201
|
201
|
return ResponseBean.error("用户名或密码错误", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
202
|
202
|
}
|
203
|
203
|
|
|
@@ -222,42 +222,31 @@ public class SysUserController extends BaseController {
|
222
|
222
|
}
|
223
|
223
|
|
224
|
224
|
@PostMapping("/center/changePassword")
|
225
|
|
- public ResponseBean changePassword(@RequestBody String paramStr) {
|
226
|
|
- JSONObject params = JSONObject.parseObject(paramStr);
|
227
|
|
- if (params == null) {
|
228
|
|
- return ResponseBean.error("非法参数", ResponseBean.ERROR_MISSING_PARAMS);
|
229
|
|
- }
|
230
|
|
- String loginPassword = params.get("loginPassword").toString();
|
231
|
|
- String newPassword = params.get("newPassword").toString();
|
232
|
|
- String confirmPassword = params.get("confirmPassword").toString();
|
|
225
|
+ public ResponseBean changePassword(@RequestParam String originalPassword,
|
|
226
|
+ @RequestParam String newPassword,HttpServletRequest request) {
|
233
|
227
|
|
234
|
|
- //校验密码
|
235
|
|
- QueryWrapper<TaUser> taUserQueryWrapper = new QueryWrapper<>();
|
236
|
|
- taUserQueryWrapper.eq("user_id", params.get("userId"));
|
237
|
|
- TaUser taUser = iTaUserService.getOne(taUserQueryWrapper);
|
|
228
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(newPassword) || newPassword.length() < 6) {
|
|
229
|
+ return ResponseBean.error("新密不能小于6位", ResponseBean.ERROR_UNAVAILABLE);
|
|
230
|
+ }
|
238
|
231
|
|
239
|
|
- if (!taUser.getLoginPassword().equals(MD5Utils.md5(MD5Utils.md5(loginPassword)))){
|
240
|
|
- return ResponseBean.error("旧密码错误,请重新输入", ResponseBean.ERROR_UNAVAILABLE);
|
241
|
|
- };
|
|
232
|
+ Integer channelId = getChannelId(request);
|
242
|
233
|
|
243
|
|
- if (StringUtils.isEmpty(newPassword) || StringUtils.isEmpty(confirmPassword)){
|
244
|
|
- return ResponseBean.error("请输入新密码", ResponseBean.ERROR_UNAVAILABLE);
|
|
234
|
+ // 校验当前旧密码是否正确
|
|
235
|
+ String password = MD5Utils.md5(MD5Utils.md5(originalPassword));
|
|
236
|
+ TaChannelProxy taChannelProxy = iTaChannelProxyService.getById(channelId);
|
|
237
|
+ if (!password.equals(taChannelProxy.getPassword())){
|
|
238
|
+ return ResponseBean.error("旧密码错误,请重新输入", ResponseBean.ERROR_UNAVAILABLE);
|
245
|
239
|
}
|
246
|
240
|
|
247
|
|
- if (!newPassword.equals(confirmPassword)){
|
248
|
|
- return ResponseBean.error("两次密码不一致,请确认重新输入", ResponseBean.ERROR_UNAVAILABLE);
|
|
241
|
+ try {
|
|
242
|
+ iTaChannelProxyService.resetPassword(channelId, newPassword);
|
|
243
|
+ return ResponseBean.success("操作成功!");
|
|
244
|
+ } catch (Exception e) {
|
|
245
|
+ e.printStackTrace();
|
|
246
|
+ return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
|
249
|
247
|
}
|
250
|
|
-
|
251
|
|
- //重置密码
|
252
|
|
- QueryWrapper<TaUser> updateWrapper = new QueryWrapper<>();
|
253
|
|
- TaUser user = new TaUser();
|
254
|
|
- user.setLoginPassword(MD5Utils.md5(MD5Utils.md5(newPassword)));
|
255
|
|
- updateWrapper.eq("user_id", params.get("userId"));
|
256
|
|
- iTaUserService.update(user, updateWrapper);
|
257
|
|
-
|
258
|
|
- return ResponseBean.success("设置成功");
|
259
|
248
|
}
|
260
|
|
-
|
|
249
|
+
|
261
|
250
|
@PostMapping("/center/signout")
|
262
|
251
|
public ResponseBean signout(HttpServletRequest request) {
|
263
|
252
|
String token = JWTUtils.getToken(request);
|