Commit b4fe6958d67ed804f8f89dcc9641e3e111c7aa6f
1 parent
43f455fc99
Exists in
master
and in
8 other branches
bug fix
重置用户密码接口
Showing 1 changed file with 3 additions and 42 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UsersController.java
View file @
b4fe695
... | ... | @@ -1017,54 +1017,15 @@ |
1017 | 1017 | |
1018 | 1018 | |
1019 | 1019 | |
1020 | - /** | |
1021 | - * 修改用户密码 | |
1022 | - */ | |
1023 | - @RequestMapping(value = "/passwords", method = RequestMethod.PUT) | |
1024 | - @TokenRequired | |
1025 | - public void updateUserPwd(HttpServletResponse httpServletResponse, | |
1026 | - HttpServletRequest request, | |
1027 | - @RequestParam(value = "oldPwd") String oldPwd, | |
1028 | - @RequestParam(value = "newPwd") String newPwd) { | |
1029 | - Map<String, Object> resultMsgMap = new HashMap<String, Object>(); | |
1030 | - if (StringUtils.isBlank(oldPwd) || StringUtils.isBlank(newPwd)) { | |
1031 | - ResultUtils.buildParameterErrorResultAndWrite(httpServletResponse); | |
1032 | - return; | |
1033 | - } | |
1034 | - //获取登录用户 | |
1035 | - LoginContext loginContext = (LoginContext) request.getAttribute("loginContext"); | |
1036 | - Users users = usersService.getUsers(loginContext.getId()); | |
1037 | 1020 | |
1038 | - if (null != users) { | |
1039 | - //修改前的密码 | |
1040 | 1021 | |
1041 | - //验证之前的密码和数据库中的密码是否一致 | |
1042 | - if (null != users && LoginUtil.md5(oldPwd).equals(users.getPwd()) && !LoginUtil.md5(newPwd).equals(users.getPwd())) { | |
1043 | - | |
1044 | - Users newUsers = new Users(); | |
1045 | - newUsers.setPwd(LoginUtil.md5(newPwd)); | |
1046 | - newUsers.setModified(new Date()); | |
1047 | - newUsers.setId(users.getId()); | |
1048 | - | |
1049 | - //修改数据库的值 | |
1050 | - usersService.updateUsers(newUsers); | |
1051 | - ResultUtils.buildSuccessResultAndWrite(httpServletResponse); | |
1052 | - } else { | |
1053 | - resultMsgMap.put(ResultUtils.ERROR_CODE, ConstantInterface.USER_PASSWORD_ERROR); | |
1054 | - resultMsgMap.put(ResultUtils.ERROR_MSG, "旧密码错误或新密码和旧密码相同"); | |
1055 | - writeJson(httpServletResponse, JsonUtil.obj2JsonString(resultMsgMap)); | |
1056 | - } | |
1057 | - } | |
1058 | - } | |
1059 | - | |
1060 | - | |
1061 | 1022 | /** |
1062 | 1023 | * 重置用户密码 |
1063 | 1024 | */ |
1064 | 1025 | @RequestMapping(value = "/passwords/reset", method = RequestMethod.PUT) |
1065 | 1026 | @TokenRequired |
1066 | - public void updatePassword(HttpServletResponse response, @RequestParam(value = "id") Integer id) { | |
1067 | - Users users = usersService.getUsers(id); | |
1027 | + public void updatePassword(HttpServletResponse response, @RequestParam(value = "userId") String id) { | |
1028 | + Users users = usersService.getUsers(Integer.valueOf(id)); | |
1068 | 1029 | if (users == null) { |
1069 | 1030 | ResultUtils.buildParameterErrorResultAndWrite(response, "用户ID不存在"); |
1070 | 1031 | return; |
... | ... | @@ -1072,7 +1033,7 @@ |
1072 | 1033 | users.setPwd(defaultPwd); |
1073 | 1034 | users.setModified(new Date()); |
1074 | 1035 | usersService.updateUsers(users); |
1075 | - LoginContext loginContext = LoginUtil.register(users.getLogincenterId().toString(), null, null, LoginUtil.md5(defaultPwd).toUpperCase(), token, typeId); | |
1036 | + LoginContext loginContext = LoginUtil.register(users.getLogincenterId().toString(), users.getPhone(),users.getAccount(), LoginUtil.md5(defaultPwd).toUpperCase(), token, typeId); | |
1076 | 1037 | if(loginContext.getErrorcode().equals(0)) { |
1077 | 1038 | ResultUtils.buildSuccessResultAndWrite(response); |
1078 | 1039 | } else { |