|
|
|
@ -12,7 +12,6 @@ import javax.servlet.http.HttpSession;
|
|
|
|
|
import com.dsideal.Sso.Interceptor.EmptyInterface;
|
|
|
|
|
import com.dsideal.Sso.Model.LoginModel;
|
|
|
|
|
import com.dsideal.Sso.Util.*;
|
|
|
|
|
import com.dsideal.SsoApplication;
|
|
|
|
|
import com.jfinal.aop.Before;
|
|
|
|
|
import com.jfinal.ext.interceptor.GET;
|
|
|
|
|
import com.jfinal.ext.interceptor.POST;
|
|
|
|
@ -57,30 +56,23 @@ public class WebLoginController extends Controller {
|
|
|
|
|
HttpServletResponse response = getResponse();
|
|
|
|
|
JSONObject resultJson = new JSONObject();
|
|
|
|
|
String requestCaptcha = captcha.toLowerCase();
|
|
|
|
|
//看看系统中是不是存在着cookie,记录本机尝试登录的失败次数
|
|
|
|
|
int error_count = 0;
|
|
|
|
|
if (getCookie("error_count") != null) {
|
|
|
|
|
error_count = Integer.parseInt(getCookie("error_count"));
|
|
|
|
|
// 获取真实验证码
|
|
|
|
|
if (getRequest().getSession().getAttribute("captcha") == null) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("msg", "验证码错误!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//如果大于3次
|
|
|
|
|
if (error_count >= 3) {
|
|
|
|
|
// 获取真实验证码
|
|
|
|
|
if (getRequest().getSession().getAttribute("captcha") == null) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("msg", "验证码错误!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
String realCaptcha = getRequest().getSession().getAttribute("captcha").toString().toLowerCase();
|
|
|
|
|
String realCaptcha = getRequest().getSession().getAttribute("captcha").toString().toLowerCase();
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(requestCaptcha) || !realCaptcha.equals(requestCaptcha)) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("msg", "验证码错误!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(requestCaptcha) || !realCaptcha.equals(requestCaptcha)) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("msg", "验证码错误!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
password = AesUtil.aesDecrypt(password);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -99,12 +91,6 @@ public class WebLoginController extends Controller {
|
|
|
|
|
&& !password.equals("DsideaL4r5t6y7u")) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("msg", "账户或密码错误!");
|
|
|
|
|
//增加一次失败次数
|
|
|
|
|
if (getCookie("error_count") != null) {
|
|
|
|
|
setCookie("error_count", String.valueOf(Integer.parseInt(getCookie("error_count")) + 1), -1);
|
|
|
|
|
} else {
|
|
|
|
|
setCookie("error_count", "1", -1);
|
|
|
|
|
}
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -112,8 +98,6 @@ public class WebLoginController extends Controller {
|
|
|
|
|
SsoLoginHelper.login(response, sessionId, loginMap);
|
|
|
|
|
resultJson.put("success", true);
|
|
|
|
|
resultJson.put("sessionId", sessionId);
|
|
|
|
|
//清除cookie
|
|
|
|
|
setCookie("error_count", "1", 0);
|
|
|
|
|
// 记录人员登录日志
|
|
|
|
|
LoginLogUtil.WriteLoginLog(loginMap.get("identity_id"), loginMap.get("person_id"), LoginLogUtil.getIpAddr(getRequest()));
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|