|
|
@@ -11,6 +11,8 @@
|
|
|
package com.yami.shop.security.comment.handler;
|
|
|
|
|
|
import cn.hutool.core.util.CharsetUtil;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.yami.shop.common.util.R;
|
|
|
import com.yami.shop.security.comment.exception.BaseYamiAuth2Exception;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -23,13 +25,14 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.PrintWriter;
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 登陆失败处理
|
|
|
*/
|
|
|
@Component
|
|
|
@Slf4j
|
|
|
public class LoginAuthFailedHandler implements AuthenticationFailureHandler {
|
|
|
-
|
|
|
+ private final ObjectMapper objectMapper = new ObjectMapper();
|
|
|
/**
|
|
|
* {@inheritDoc}
|
|
|
*/
|
|
|
@@ -48,7 +51,8 @@ public class LoginAuthFailedHandler implements AuthenticationFailureHandler {
|
|
|
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
|
|
|
response.setStatus(auth2Exception.getHttpErrorCode());
|
|
|
PrintWriter printWriter = response.getWriter();
|
|
|
- printWriter.append(auth2Exception.getMessage());
|
|
|
+ objectMapper.writeValue(printWriter, R.FAIL(auth2Exception.getMessage()));
|
|
|
+// printWriter.append(auth2Exception.getMessage());
|
|
|
}
|
|
|
|
|
|
}
|