提交 d52ada59 authored 作者: renjiancai's avatar renjiancai

--no commit message

上级 ba2ef77e
......@@ -96,10 +96,11 @@ public class UserController {
}
String ip = CusAccessObjectUtil.getIpAddress(request);
String errorCount = redis.get(ip);
//账号或密码错误 5次以上 需填写验证码
/*String errorCount = stringRedisTemplate.opsForValue().get(name);*/
if(StringUtils.isNotBlank(errorCount) && Integer.parseInt(errorCount) >=5){
/*if(StringUtils.isNotBlank(errorCount) && Integer.parseInt(errorCount) >=5){
throw new BaseException(ResponseCodeEnum.VALIDATE);//密码输入错误次数过多,输入验证码
}
}*/
if(StringUtils.isNotBlank(errorCount) && Integer.parseInt(errorCount) >=5){
if(code == null){
throw new BaseException("验证码不能为空");
......@@ -118,6 +119,8 @@ public class UserController {
throw new BaseException("该账户已禁用");
}
if(password == null || !password.toLowerCase().equals(user.getPassword().toLowerCase())){
errorCount = StringUtils.isBlank(errorCount) ? "1" : Integer.parseInt(errorCount) + 1 + "";
redis.set(ip,errorCount, 60 * 5);
throw new BaseException("账号或密码错误");
}
//查看账号是否冻结
......
......@@ -3,6 +3,7 @@ package com.zrqx.resource.commons;
import java.io.IOException;
import java.util.Enumeration;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
......@@ -106,5 +107,18 @@ public class Redis {
public static String getFgToken(){
return getToken(FG_TOKEN);
}
/**
* 获取前台登录用户信息
*
* @return
*/
public String fmtObj(Object obj) throws IOException {
return obj instanceof String ? obj.toString():JsonUtil.bean2Json(obj);
}
public void set(String token, Object obj, long timeout,TimeUnit unit) throws IOException {
stringRedisTemplate.opsForValue().set(token,fmtObj(obj),timeout,unit);
}
public void set(String token, Object obj, long timeout) throws IOException {
stringRedisTemplate.opsForValue().set(token,fmtObj(obj),timeout,TimeUnit.SECONDS);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论