|
|
@ -38,144 +38,6 @@ public class LoginPersonController extends Controller {
|
|
|
|
//实例化model
|
|
|
|
//实例化model
|
|
|
|
LoginPersonModel model = new LoginPersonModel();
|
|
|
|
LoginPersonModel model = new LoginPersonModel();
|
|
|
|
|
|
|
|
|
|
|
|
@ActionApi(remark = "验证登录", summary = "验证登录", sort = 1)
|
|
|
|
|
|
|
|
@Params({
|
|
|
|
|
|
|
|
@Param(name = "username", remark = "用户名", required = true),
|
|
|
|
|
|
|
|
@Param(name = "password", remark = "密码", required = true),
|
|
|
|
|
|
|
|
@Param(name = "captcha", remark = "验证码", required = true)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
public void touPiaodoLogin(String username, String password, String captcha) {
|
|
|
|
|
|
|
|
JSONObject resultJson = new JSONObject();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (StrKit.isBlank(captcha)) {
|
|
|
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
|
|
|
resultJson.put("message", "验证码不能为空!");
|
|
|
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (getSession().getAttribute("captcha") == null) {
|
|
|
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
|
|
|
resultJson.put("message", "在浏览器会话中没有检查到验证码,你的行为将会记录!");
|
|
|
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String memory_captcha = getSession().getAttribute("captcha").toString().toLowerCase();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//验证码错误次数
|
|
|
|
|
|
|
|
String checkCodeKey = "Yzm_error_" + username;
|
|
|
|
|
|
|
|
int CheckCodeErrCnt = 4; //最多允许错几次 4+1
|
|
|
|
|
|
|
|
int CheckCodecntNum = 0; //错几次了
|
|
|
|
|
|
|
|
if (Redis.use().exists(checkCodeKey))
|
|
|
|
|
|
|
|
CheckCodecntNum = Integer.parseInt(Redis.use().get(checkCodeKey).toString());
|
|
|
|
|
|
|
|
if (CheckCodecntNum > CheckCodeErrCnt) {
|
|
|
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
|
|
|
resultJson.put("message", "账号已被停用5分钟,请稍后再试!");
|
|
|
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!memory_captcha.equals(captcha.toLowerCase())) {
|
|
|
|
|
|
|
|
CheckCodecntNum = 1;
|
|
|
|
|
|
|
|
if (Redis.use().exists(checkCodeKey))
|
|
|
|
|
|
|
|
CheckCodecntNum = Integer.parseInt(Redis.use().get(checkCodeKey).toString()) + CheckCodecntNum;
|
|
|
|
|
|
|
|
Redis.use().set(checkCodeKey, CheckCodecntNum);
|
|
|
|
|
|
|
|
Redis.use().expire(checkCodeKey, 60 * 5);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CheckCodecntNum == CheckCodeErrCnt) {
|
|
|
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
|
|
|
resultJson.put("message", "验证码连续输入错误" + CheckCodecntNum + "次,再错误一次将被封号5分钟!");
|
|
|
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CheckCodecntNum > CheckCodeErrCnt) {
|
|
|
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
|
|
|
resultJson.put("message", "验证码连续输入错误5次,账号被停用5分钟,请稍后再试!");
|
|
|
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
|
|
|
resultJson.put("message", "验证码不正确!");
|
|
|
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StrKit.isBlank(username)) {
|
|
|
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
|
|
|
resultJson.put("message", "用户名不允许为空!");
|
|
|
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StrKit.isBlank(password)) {
|
|
|
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
|
|
|
resultJson.put("message", "密码不允许为空!");
|
|
|
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//检查缓存中此账号错误了几次
|
|
|
|
|
|
|
|
String PassWordKey = "WrongPassWord_" + username;
|
|
|
|
|
|
|
|
int ErrCnt = 4; //最多允许错几次 4+1
|
|
|
|
|
|
|
|
int cntNum = 0; //错几次了
|
|
|
|
|
|
|
|
if (Redis.use().exists(PassWordKey)) cntNum = Integer.parseInt(Redis.use().get(PassWordKey).toString());
|
|
|
|
|
|
|
|
if (cntNum > ErrCnt) {
|
|
|
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
|
|
|
resultJson.put("message", "账号被停用5分钟,请稍后再试!");
|
|
|
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//与前端配合RSA通用加密解密
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
password = RsaUtils.decryptDataOnJava(password, RsaUtils.PRIVATEKEY);
|
|
|
|
|
|
|
|
} catch (Exception err) {
|
|
|
|
|
|
|
|
password = "!@#$%^&&*^*&(*)(*_)^%^$%$^%$^%";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String sql = "select * from t_toupiao_toupiaoren where toupiaoren_tel=?";
|
|
|
|
|
|
|
|
List<Record> list = Db.find(sql, username);
|
|
|
|
|
|
|
|
if (list.size() == 0) {
|
|
|
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
|
|
|
resultJson.put("message", "用户名或密码错误!");
|
|
|
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!password.equals(username.substring(username.length() - 6))) {
|
|
|
|
|
|
|
|
//扩展支持连续输入用户名密码错误,停用账号5分钟功能 2022.06.07
|
|
|
|
|
|
|
|
cntNum = 1;
|
|
|
|
|
|
|
|
if (Redis.use().exists(PassWordKey))
|
|
|
|
|
|
|
|
cntNum = Integer.parseInt(Redis.use().get(PassWordKey).toString()) + cntNum;
|
|
|
|
|
|
|
|
Redis.use().set(PassWordKey, cntNum);
|
|
|
|
|
|
|
|
Redis.use().expire(PassWordKey, 60 * 5);
|
|
|
|
|
|
|
|
if (cntNum > ErrCnt) {
|
|
|
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
|
|
|
resultJson.put("message", "密码连续输入" + (ErrCnt + 1) + "次全部错误,账号将被停用5分钟!");
|
|
|
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cntNum == ErrCnt) {
|
|
|
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
|
|
|
resultJson.put("message", "用户名或密码连续错误,你还有1次机会,再次错误后账号将被封掉5分钟!");
|
|
|
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
|
|
|
resultJson.put("message", "用户名或密码错误!");
|
|
|
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//去掉限制
|
|
|
|
|
|
|
|
Redis.use().del(PassWordKey);
|
|
|
|
|
|
|
|
Redis.use().del(checkCodeKey);
|
|
|
|
|
|
|
|
CookieUtil.set(getResponse(), "toupiaoren_tel", username, false, true);
|
|
|
|
|
|
|
|
resultJson.put("success", true);
|
|
|
|
|
|
|
|
resultJson.put("toupiaoren_tel", username);
|
|
|
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
|
|
|
resultJson.put("message", "登录异常!");
|
|
|
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ActionApi(remark = "验证登录", summary = "验证登录", sort = 1)
|
|
|
|
@ActionApi(remark = "验证登录", summary = "验证登录", sort = 1)
|
|
|
|
@Params({
|
|
|
|
@Params({
|
|
|
|
@Param(name = "username", remark = "用户名", required = true),
|
|
|
|
@Param(name = "username", remark = "用户名", required = true),
|
|
|
@ -260,12 +122,6 @@ public class LoginPersonController extends Controller {
|
|
|
|
renderJson(resultJson);
|
|
|
|
renderJson(resultJson);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//与前端配合RSA通用加密解密
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
password = RsaUtils.decryptDataOnJava(password, RsaUtils.PRIVATEKEY);
|
|
|
|
|
|
|
|
} catch (Exception err) {
|
|
|
|
|
|
|
|
password = "!@#$%^&&*^*&(*)(*_)^%^$%$^%$^%";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String passwordEncode = CommonUtil.getLdapPassword(password);
|
|
|
|
String passwordEncode = CommonUtil.getLdapPassword(password);
|
|
|
|
BaseModel bm = new BaseModel();
|
|
|
|
BaseModel bm = new BaseModel();
|
|
|
|
Map loginMap = bm.getLoginInfoByUserName(username);
|
|
|
|
Map loginMap = bm.getLoginInfoByUserName(username);
|
|
|
|