登录错误的信息返回给客户端

This commit is contained in:
cl
2021-07-29 14:25:11 +08:00
parent 9bf5f19fa4
commit dd38916f72
3 changed files with 5 additions and 5 deletions

View File

@@ -10,7 +10,7 @@
package com.yami.shop.security.exception;
public class UsernameNotFoundException extends YamiAuth2Exception {
public class UsernameNotFoundException extends BaseYamiAuth2Exception {
public UsernameNotFoundException(String msg) {
super(msg);

View File

@@ -45,10 +45,10 @@ public class LoginAuthFailedHandler implements AuthenticationFailureHandler {
BaseYamiAuth2Exception auth2Exception = (BaseYamiAuth2Exception) exception;
response.setCharacterEncoding(CharsetUtil.UTF_8);
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.setStatus(auth2Exception.getHttpErrorCode());
PrintWriter printWriter = response.getWriter();
printWriter.append(auth2Exception.getMessage());
}
}
}