| | |
| | | public String updatePassword(Model model) { |
| | | return "/password.html" ; |
| | | } |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | /** |
| | | * 点击登录执行的动作 |
| | | */ |
| | | @RequestMapping(value = "/updatePassword", method = RequestMethod.POST) |
| | | public Object loginVali(String username, String password,String code) { |
| | | |
| | | User user = userService.getByAccount(username); |
| | | if (user==null)return "用户不存在"; |
| | | password = AESUtils.decrypt(password); |
| | | String s = MD5.md5(password); |
| | | if(user.getPassword().equals(s))return "新密码和旧密码一致"; |
| | | //验证短信验证码 |
| | | if(ToolUtil.isEmpty(code))return "无效的验证码"; |
| | | String value = redisUtil.getValue(user.getPhone()); |
| | | if(ToolUtil.isEmpty(value) || !code.equals(value))return "手机验证码不正确"; |
| | | user.setPassword(s); |
| | | return "修改成功!"; |
| | | } |
| | | // @Autowired |
| | | // private RedisUtil redisUtil; |
| | | // /** |
| | | // * 点击登录执行的动作 |
| | | // */ |
| | | // @RequestMapping(value = "/updatePassword", method = RequestMethod.POST) |
| | | // public Object loginVali(String username, String password,String code) { |
| | | // |
| | | // User user = userService.getByAccount(username); |
| | | // if (user==null)return "用户不存在"; |
| | | // password = AESUtils.decrypt(password); |
| | | // String s = MD5.md5(password); |
| | | // if(user.getPassword().equals(s))return "新密码和旧密码一致"; |
| | | // //验证短信验证码 |
| | | // if(ToolUtil.isEmpty(code))return "无效的验证码"; |
| | | // String value = redisUtil.getValue(user.getPhone()); |
| | | // if(ToolUtil.isEmpty(value) || !code.equals(value))return "手机验证码不正确"; |
| | | // user.setPassword(s); |
| | | // return "修改成功!"; |
| | | // } |
| | | /** |
| | | * 跳转到主页 |
| | | */ |
| | |
| | | f++; |
| | | loginFailures.put(username, f); |
| | | } |
| | | if (KaptchaUtil.getKaptchaOnOff()) { |
| | | String kaptcha = super.getPara("kaptcha").trim(); |
| | | String code = (String) super.getSession().getAttribute(Constants.KAPTCHA_SESSION_KEY); |
| | | if (Objects.isNull(kaptcha) || !kaptcha.equalsIgnoreCase(code)) { |
| | | model.addAttribute("tips", "验证码错误"); |
| | | return "/login.html"; |
| | | } |
| | | } |
| | | |
| | | // if (f > 5 && (System.currentTimeMillis() - t) <= (30 * 60 * 1000)) { |
| | | // model.addAttribute("tips", "登录次数过多,请等30分钟再试!"); |
| | | // return "/login.html"; |