Răsfoiți Sursa

Merge branch 'develop' into develop-debt

* develop:
  更新登陆帐号错误返回由401返回200
mac 2 ani în urmă
părinte
comite
7e50a3203a

+ 2 - 2
kxs-common/kxs-common-security/src/main/java/com/kxs/common/security/service/KxsAppUserServiceImpl.java

@@ -40,10 +40,10 @@ public class KxsAppUserServiceImpl implements KxsUserDetailsService{
         R<KxsUser> result = remoteKxsUserService.loadUserByPhone(username, SecurityConstants.FROM_IN);
         KxsUser custom = RetOps.of(result)
                 .getData()
-                .orElseThrow(() -> new UsernameNotFoundException(ErrorTypeEnum.BAD_CREDENTIALS.getDescription()));
+                .orElseThrow(() -> new UsernameNotFoundException(ErrorTypeEnum.USER_NOT_FOUND.getDescription()));
 
         if(Objects.equals(custom.getStatus(), UserStatusEnum.REMOVE.getCode())){
-            throw new UsernameNotFoundException(ErrorTypeEnum.BAD_CREDENTIALS.getDescription());
+            throw new UsernameNotFoundException(ErrorTypeEnum.ACCOUNT_DISABLED.getDescription());
         }
         if(Objects.equals(custom.getStatus(), UserStatusEnum.LOCKED.getCode())){
             throw new LockedException(ErrorTypeEnum.ACCOUNT_LOCKED.getDescription());

+ 3 - 2
kxs-common/kxs-common-security/src/main/java/com/kxs/common/security/support/core/SkyDaoAuthenticationProvider.java

@@ -67,6 +67,7 @@ public class SkyDaoAuthenticationProvider extends AbstractUserDetailsAuthenticat
 	public SkyDaoAuthenticationProvider(String active) {
 		this.active = active;
 		setMessageSource(SpringUtil.getBean("securityMessageSource"));
+		setHideUserNotFoundExceptions(false);
 		setPasswordEncoder(PasswordEncoderFactories.createDelegatingPasswordEncoder());
 	}
 
@@ -93,7 +94,7 @@ public class SkyDaoAuthenticationProvider extends AbstractUserDetailsAuthenticat
 			throw new BadCredentialsException(ErrorTypeEnum.BAD_CREDENTIALS.getDescription());
 		}
 		//开发和环境去掉密码验证
-		if(!"dev".equals(active) && !"test".equals(active)){
+//		if(!"dev".equals(active) && !"test".equals(active)){
 			String presentedPassword = authentication.getCredentials().toString();
 			if(userDetails instanceof KxsSecurityUser user && (CharSequenceUtil.isNotBlank(user.getSalt()))){
 				presentedPassword = presentedPassword + user.getSalt();
@@ -103,7 +104,7 @@ public class SkyDaoAuthenticationProvider extends AbstractUserDetailsAuthenticat
 				this.logger.debug("Failed to authenticate since password does not match stored value");
 				throw new BadCredentialsException(ErrorTypeEnum.BAD_CREDENTIALS.getDescription());
 			}
-		}
+//		}
 	}
 
 	@SneakyThrows

+ 1 - 1
kxs-common/kxs-common-security/src/main/java/com/kxs/common/security/support/handler/SkyAuthenticationFailureEventHandler.java

@@ -69,7 +69,7 @@ public class SkyAuthenticationFailureEventHandler implements AuthenticationFailu
 	private void sendErrorResponse(HttpServletRequest request, HttpServletResponse response,
 			AuthenticationException exception) throws IOException {
 		ServletServerHttpResponse httpResponse = new ServletServerHttpResponse(response);
-		httpResponse.setStatusCode(HttpStatus.UNAUTHORIZED);
+		httpResponse.setStatusCode(HttpStatus.OK);
 		String errorMessage;
 
 		if (exception instanceof OAuth2AuthenticationException authorizationException) {