Commit 3a5255f4 by chenzx

单点登录方式改造,登录失败返回中文提示

parent 438b61e8
......@@ -27,17 +27,26 @@ public class RESTAuthenticationFailureHandler extends SimpleUrlAuthenticationFai
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
AuthenticationException exception) throws IOException, ServletException {
//super.onAuthenticationFailure(request, response, exception);
response.setHeader("Content-type", "text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
String username = request.getParameter("username");
String password = request.getParameter("password");
System.out.println("登陆失败信息:"+username+"#######"+password);
if(rateLimitService.reached(username)){
System.out.println("锁定了账户:"+username);
redisTemplate.opsForValue().set("LOCK_USER_"+username,true,10, TimeUnit.MINUTES);
if(null == redisTemplate.opsForValue().get("LOCK_USER_"+username)){
redisTemplate.opsForValue().set("LOCK_USER_"+username,true,10, TimeUnit.MINUTES);
}
PrintWriter writer = response.getWriter();
writer.write("您已连续登录失败超过5次,账号已被锁定10分钟。");
writer.flush();
writer.close();
}else{
PrintWriter writer = response.getWriter();
writer.write("账号或者密码错误,请重新输入。");
writer.flush();
writer.close();
}
PrintWriter writer = response.getWriter();
writer.write("您已连续登录失败超过5次,账号已被锁定10分钟。");
writer.flush();
writer.close();
}
}
......@@ -39,6 +39,8 @@ public class RESTAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuc
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws IOException, ServletException {
clearAuthenticationAttributes(request);
response.setHeader("Content-type", "text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
System.out.println("come onAuthenticationSuccess here");
String sso = (String) request.getSession().getAttribute("ssologin");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment