mirror of
https://gitee.com/gz-yami/mall4j.git
synced 2026-03-22 09:17:16 +08:00
登录错误的信息返回给客户端
This commit is contained in:
@@ -138,10 +138,10 @@ public class YamiUserServiceImpl implements YamiUserDetailsService {
|
||||
if (user == null) {
|
||||
throw new UsernameNotFoundException("用户不存在");
|
||||
}
|
||||
String paramPassword = passwordEncoder.encode(loginPassword);
|
||||
|
||||
if (!passwordEncoder.matches(loginPassword, user.getLoginPassword())) {
|
||||
// 原密码不正确
|
||||
throw new YamiShopBindException("密码不正确");
|
||||
throw new UsernameNotFoundException("密码不正确");
|
||||
}
|
||||
String name = StrUtil.isBlank(user.getRealName()) ? user.getNickName() : user.getRealName();
|
||||
YamiUser yamiUser = new YamiUser(user.getUserId(), loginPassword, user.getStatus() == 1);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user