forked from pzk9h3i5c/c7-523
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1004 B
26 lines
1004 B
package com.qsd.orange.security;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.qsd.orange.global.HttpResult;
|
|
import com.qsd.orange.global.R;
|
|
import org.springframework.security.core.AuthenticationException;
|
|
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
import javax.servlet.ServletException;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.IOException;
|
|
|
|
@Controller
|
|
public class LoginFailureHandler implements AuthenticationFailureHandler {
|
|
|
|
@Override
|
|
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
|
|
response.setCharacterEncoding("utf-8");
|
|
response.setContentType("application/json;charset=utf-8");
|
|
response.getWriter().print(JSONUtil.toJsonStr(R.error(HttpResult.USERNAME_OR_PASSWORD_ERROR)));
|
|
}
|
|
|
|
}
|