提交 55ab8a80 authored 作者: yucaiwei's avatar yucaiwei

--no commit message

上级 c3a82924
......@@ -113,17 +113,31 @@ public class FgPermissionsController {
}
String ip = CusAccessObjectUtil.getIpAddress(request);
String errorCount = redis.get(ip);
//账号或密码错误 5次以上 需填写验证码
if (StringUtils.isNotBlank(errorCount) && Integer.parseInt(errorCount) > 5) {
if (form.getCode() == null) {
throw new BaseException(2,"验证码不能为空");
// PC端
if(form.getChannel() == null || form.getChannel() == 0){
//账号或密码错误 5次以上 需填写验证码
if (StringUtils.isNotBlank(errorCount) && Integer.parseInt(errorCount) > 5) {
if (form.getCode() == null) {
throw new BaseException(2,"验证码不能为空");
}
String redisCode = redis.get(form.getUuid());
if(!this.VerificationCode(form, redisCode, ip)){
throw new BaseException(3,"验证码有误");
}
}
String redisCode = redis.get(form.getUuid());
if (form.getCode() == null || redisCode == null || !form.getCode().toLowerCase().equals(redisCode.toLowerCase())) {
llService.save(form.getAccount(), ip, 0, form.getChannel(), "验证码有误");
throw new BaseException(3,"验证码有误");
}
// WAP端
if(form.getChannel() != null && form.getChannel() == 1){
//账号或密码错误 3次以上 需填写验证码
if (StringUtils.isNotBlank(errorCount) && Integer.parseInt(errorCount) > 3) {
if (form.getCode() == null) {
throw new BaseException(2,"验证码不能为空");
}
String redisCode = redis.get(form.getUuid());
if(!this.VerificationCode(form, redisCode, ip)){
throw new BaseException(3,"验证码有误");
}
}
redis.delete(form.getUuid());
}
boolean isExist = mService.isExistByAccount(null, form.getAccount());
if(!isExist) {
......@@ -167,8 +181,7 @@ public class FgPermissionsController {
throw new BaseException(2,"验证码不能为空");
}
String redisCode = redis.get(form.getAccount());
if (form.getCode() == null || redisCode == null || !form.getCode().toLowerCase().equals(redisCode.toLowerCase())) {
llService.save(form.getAccount(), ip, 0, form.getChannel(), "验证码有误");
if(!this.VerificationCode(form, redisCode, ip)){
throw new BaseException(3,"验证码有误");
}
if(!mService.isExistByPhone(null, form.getAccount())) {
......@@ -615,4 +628,23 @@ public class FgPermissionsController {
}
return source;
}
/**
* 验证验证码
* @param form
* @param redisCode
* @param ip
* @return
* @throws IOException
* @author ycw
* @date: 2019年6月18日 下午5:43:38
*/
private boolean VerificationCode(LoginForm form, String redisCode, String ip) throws IOException {
if (form.getCode() == null || redisCode == null || !form.getCode().toLowerCase().equals(redisCode.toLowerCase())) {
llService.save(form.getAccount(), ip, 0, form.getChannel(), "验证码有误");
return false;
}
redis.delete(form.getUuid());
return true;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论