//发送短信
@RequestMapping(value = "/sendCode", method = RequestMethod.GET)
@ResponseBody
public void sendCode( String cellphone, String uuid,String vercode, HttpServletRequest request) {
String code = (String) WebUtils.getSessionAttribute(request, AdminConstant.LOGIN_CAPTCHA);
if (!code.toLowerCase().equals(vercode.toLowerCase())) {
fail(StateCode.VCODE_ERROR);
return;
}
String s = String.valueOf((int) (Math.random() * 9000) + 1000);
smsService.sendCode(cellphone, s);
captchaCloudManager.setMobile(uuid, cellphone, s);
success();
}
//校验短信
@RequestMapping(value = "/checkCode", method = RequestMethod.GET)
@ResponseBody
public void checkCode( String cellphone, String uuid,String smscode) {
JSONObject json = new JSONObject();
String mobileCode = captchaCloudManager.getMobile(uuid, cellphone);
if (smscode.equalsIgnoreCase(mobileCode)){
json.put("request",true);
}else {
json.put("request",false);
}
success(json);
}
//修改密码
@RequestMapping(value = "/resPassword", method = RequestMethod.GET)
@ResponseBody
public void resPassword( String password, String repass,String mobile) {
JSONObject json = new JSONObject();
if (password.equalsIgnoreCase(repass)){
AuthorUser user = authorUserManager.findByPhone(mobile);
user.setPassword(MD5.md5(AdminConstant.PASSWORD_PREFIX+password+AdminConstant.PASSWORD_SUFFIX));
authorUserManager.update(user);
}else {
json.put("request",false);
}
success(json);
}
layui发送短信验证码 (二)后台接收及校验
最新推荐文章于 2022-01-18 11:02:11 发布