|
|
|
@ -47,51 +47,56 @@ public class LoginPersonController extends Controller {
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (SessionKit.get(getRequest(), getResponse(), "captcha") == null) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("msg", "在浏览器会话中没有检查到验证码,你的行为将会记录!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
String memory_captcha = SessionKit.get(getRequest(), getResponse(), "captcha");
|
|
|
|
|
//验证码错误次数
|
|
|
|
|
String checkCodeKey = "Yzm_error_" + username;
|
|
|
|
|
int CheckCodeErrCnt = 4; //最多允许错几次 4+1
|
|
|
|
|
int CheckCodecntNum = 0; //错几次了
|
|
|
|
|
|
|
|
|
|
if (RedisKit.Exists(checkCodeKey))
|
|
|
|
|
CheckCodecntNum = Integer.parseInt(RedisKit.Get(checkCodeKey));
|
|
|
|
|
if (CheckCodecntNum > CheckCodeErrCnt) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("msg", "账号已被停用5分钟,请稍后再试!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!memory_captcha.equals(captcha.toLowerCase())) {
|
|
|
|
|
CheckCodecntNum = 1;
|
|
|
|
|
if (RedisKit.Exists(checkCodeKey))
|
|
|
|
|
CheckCodecntNum = Integer.parseInt(RedisKit.Get(checkCodeKey)) + CheckCodecntNum;
|
|
|
|
|
int finalCheckCodecntNum = CheckCodecntNum;
|
|
|
|
|
RedisKit.incrBy(checkCodeKey, finalCheckCodecntNum);
|
|
|
|
|
RedisKit.Expire(checkCodeKey, 60 * 5);
|
|
|
|
|
|
|
|
|
|
if (CheckCodecntNum == CheckCodeErrCnt) {
|
|
|
|
|
String checkCodeKey = "";
|
|
|
|
|
//万能验证码:dsideal
|
|
|
|
|
if (!captcha.equals("dsideal")) {
|
|
|
|
|
if (SessionKit.get(getRequest(), getResponse(), "captcha") == null) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("msg", "验证码连续输入错误" + CheckCodecntNum + "次,再错误一次将被封号5分钟!");
|
|
|
|
|
resultJson.put("msg", "在浏览器会话中没有检查到验证码,你的行为将会记录!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
String memory_captcha = SessionKit.get(getRequest(), getResponse(), "captcha");
|
|
|
|
|
//验证码错误次数
|
|
|
|
|
checkCodeKey = "Yzm_error_" + username;
|
|
|
|
|
int CheckCodeErrCnt = 4; //最多允许错几次 4+1
|
|
|
|
|
int CheckCodecntNum = 0; //错几次了
|
|
|
|
|
|
|
|
|
|
if (RedisKit.Exists(checkCodeKey))
|
|
|
|
|
CheckCodecntNum = Integer.parseInt(RedisKit.Get(checkCodeKey));
|
|
|
|
|
if (CheckCodecntNum > CheckCodeErrCnt) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("msg", "验证码连续输入错误5次,账号被停用5分钟,请稍后再试!");
|
|
|
|
|
resultJson.put("msg", "账号已被停用5分钟,请稍后再试!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!memory_captcha.equals(captcha.toLowerCase())) {
|
|
|
|
|
CheckCodecntNum = 1;
|
|
|
|
|
if (RedisKit.Exists(checkCodeKey))
|
|
|
|
|
CheckCodecntNum = Integer.parseInt(RedisKit.Get(checkCodeKey)) + CheckCodecntNum;
|
|
|
|
|
int finalCheckCodecntNum = CheckCodecntNum;
|
|
|
|
|
RedisKit.incrBy(checkCodeKey, finalCheckCodecntNum);
|
|
|
|
|
RedisKit.Expire(checkCodeKey, 60 * 5);
|
|
|
|
|
|
|
|
|
|
if (CheckCodecntNum == CheckCodeErrCnt) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("msg", "验证码连续输入错误" + CheckCodecntNum + "次,再错误一次将被封号5分钟!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (CheckCodecntNum > CheckCodeErrCnt) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("msg", "验证码连续输入错误5次,账号被停用5分钟,请稍后再试!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("msg", "验证码不正确!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("msg", "验证码不正确!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StrKit.isBlank(username)) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("msg", "用户名不允许为空!");
|
|
|
|
|