main
HuangHai 2 months ago
parent 8bced45ca8
commit 970e1acb02

@ -50,9 +50,11 @@
<input name="smsCaptcha" type="text" id="captchaTxt" class="input-yzm" maxlength="4" <input name="smsCaptcha" type="text" id="captchaTxt" class="input-yzm" maxlength="4"
autocomplete="off"/> autocomplete="off"/>
<span class="span-yzm"> <span class="span-yzm">
<img id="userCaptchaImage" src="/dsSso/getCaptcha?id=1" title="点击图片刷新校验码" alt="点击图片刷新校验码" <img id="userCaptchaImage" src="/dsSso/getCaptcha?id=1" title="点击图片刷新校验码"
alt="点击图片刷新校验码"
style="cursor:pointer" onclick="javascript:refreshCaptcha()"/> style="cursor:pointer" onclick="javascript:refreshCaptcha()"/>
<a onclick="javascript:refreshCaptcha()" class="forget-pass" style="cursor:pointer">换一张</a></span> <a onclick="javascript:refreshCaptcha()" class="forget-pass"
style="cursor:pointer">换一张</a></span>
</dd> </dd>
</dl> </dl>
<div class="btn-box clearfix" style="margin-top: 10px;"> <div class="btn-box clearfix" style="margin-top: 10px;">
@ -84,29 +86,11 @@
} }
return ""; return "";
} }
window.checkYzm=function(){
//通过阅读cookie中的error_count是否存在是否大于3来决定是否显示验证码
if (getCookie("error_count") == "" || parseInt(getCookie("error_count")) < 3) {
//隐藏掉验证码
$("#captchaTxt").val("1234");
$("#yzm").hide();
}else{
$("#yzm").show();
$("#captchaTxt").val("");
}
}
checkYzm();
$("#smsLoginBtn").click(function () {
var smsFlag = $("#smsFlagHidden").val();
var smsCode = $("#smsCode").val();
var phonenum = $("#phoneTxt").val();
smsLogin(smsFlag, smsCode, phonenum);
});
$("#yzm").show();
$("#captchaTxt").val("");
//获取页面信息,包括系统名称,版权信息 //获取页面信息,包括系统名称,版权信息
getPageInfo(); getPageInfo();
}); });
$(document).keydown(function (event) { $(document).keydown(function (event) {
@ -347,6 +331,7 @@
} }
}); });
} }
// 找回密码 // 找回密码
$("#findPwd").click(function () { $("#findPwd").click(function () {
window.open('./pwdfind/pwdfind.html'); window.open('./pwdfind/pwdfind.html');

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

@ -68,5 +68,4 @@ public class LoginModel {
} }
return result; return result;
} }
} }

@ -1,4 +1,4 @@
package Plugin; package com.dsideal.Sso.Plugin;
import com.jfinal.log.Log; import com.jfinal.log.Log;
import org.slf4j.Logger; import org.slf4j.Logger;

@ -1,4 +1,4 @@
package Plugin; package com.dsideal.Sso.Plugin;
import com.jfinal.log.ILogFactory; import com.jfinal.log.ILogFactory;
import com.jfinal.log.Log; import com.jfinal.log.Log;

@ -6,7 +6,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.dsideal.SsoApplication; import com.dsideal.SsoApplication;
import com.jfinal.kit.PropKit;
public class SsoLoginHelper { public class SsoLoginHelper {

@ -1,6 +1,6 @@
package com.dsideal; package com.dsideal;
import Plugin.LogBackLogFactory; import com.dsideal.Sso.Plugin.LogBackLogFactory;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import com.dsideal.Sso.Interceptor.EmptyInterceptor; import com.dsideal.Sso.Interceptor.EmptyInterceptor;
import com.dsideal.Sso.Util.YamlProp; import com.dsideal.Sso.Util.YamlProp;
@ -8,7 +8,6 @@ import com.jfinal.config.*;
import com.jfinal.kit.Prop; import com.jfinal.kit.Prop;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin; import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.dialect.MysqlDialect; import com.jfinal.plugin.activerecord.dialect.MysqlDialect;
import com.jfinal.plugin.activerecord.dialect.MysqlDialect;
import com.jfinal.plugin.druid.DruidPlugin; import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.plugin.redis.RedisPlugin; import com.jfinal.plugin.redis.RedisPlugin;
import com.jfinal.server.undertow.UndertowServer; import com.jfinal.server.undertow.UndertowServer;

@ -13,9 +13,8 @@ redis:
sso: sso:
sessionid: ds_sso_sessionid sessionid: ds_sso_sessionid
log: # 可以登录的身份
# 记录登录日志的范围 loginLogIdentity: 1,2,3,4,5,6,7
loginLogIdentity: 1,2,3,4,5,6,7
password: password:
# MysqlAES加密解密的密码 # MysqlAES加密解密的密码

Loading…
Cancel
Save