/** * @param oldpwd * @param newpwd * @param request * @return @Description:重置密码 */ @ResponseBody @RequestMapping("/rePassword") public String rePassword(String oldpwd, String newpwd, HttpServletRequest request) { SimpleReturnVo vo; User user = WebUtils.getLoginUser(request); String password = MD5Util.getMD5String(PrivilegeConstant.USER_PASSWORD_FRONT + oldpwd); if (!password.equals(user.getPassword())) { vo = new SimpleReturnVo(this.FAIL, "原密码不正确!"); return JsonUtils.toJson(vo); } try { User newUser = new User(); newUser.setId(user.getId()); password = MD5Util.getMD5String(PrivilegeConstant.USER_PASSWORD_FRONT + newpwd); newUser.setPassword(password); this.userService.singleUpdateUser(newUser); vo = new SimpleReturnVo(this.SUCCESS, "成功"); } catch (Exception e) { e.printStackTrace(); logger.debug("UserController-rePassword:"******"异常错误!"); } return JsonUtils.toJson(vo); }
/** * @param request * @return @Description:修改密码 */ @ResponseBody @RequestMapping("/updatePassowrd") public String updatePassowrd(User user) { SimpleReturnVo vo; String password = MD5Util.getMD5String(PrivilegeConstant.USER_PASSWORD_FRONT + user.getPassword()); try { user.setPassword(password); this.userService.singleUpdateUser(user); vo = new SimpleReturnVo(this.SUCCESS, "成功"); } catch (Exception e) { e.printStackTrace(); logger.debug("UserController-updatePassowrd:" + e.getMessage()); vo = new SimpleReturnVo(this.FAIL, "异常错误!"); } return JsonUtils.toJson(vo); }