diff --git a/cloud-common/cloud-common-security/src/main/java/cn/sh/stc/sict/cloud/common/security/component/SictWebResponseExceptionTranslator.java b/cloud-common/cloud-common-security/src/main/java/cn/sh/stc/sict/cloud/common/security/component/SictWebResponseExceptionTranslator.java index bd68dae418bc1a300db612f3f3aa90aacda2ec25..1a437b3a8ba31d094f81676f1898f11a2c3fcd8d 100644 --- a/cloud-common/cloud-common-security/src/main/java/cn/sh/stc/sict/cloud/common/security/component/SictWebResponseExceptionTranslator.java +++ b/cloud-common/cloud-common-security/src/main/java/cn/sh/stc/sict/cloud/common/security/component/SictWebResponseExceptionTranslator.java @@ -35,13 +35,14 @@ public class SictWebResponseExceptionTranslator implements WebResponseExceptionT // Try to extract a SpringSecurityException from the stacktrace Throwable[] causeChain = throwableAnalyzer.determineCauseChain(e); + Exception ase = (AccountLockedException) throwableAnalyzer.getFirstThrowableOfType(AccountLockedException.class, causeChain); + if(ase != null){ + return handleOAuth2Exception(new UnauthorizedException(e.getMessage(), e, HttpStatus.LOCKED.value())); + } - Exception ase = (AuthenticationException) throwableAnalyzer.getFirstThrowableOfType(AuthenticationException.class, + ase = (AuthenticationException) throwableAnalyzer.getFirstThrowableOfType(AuthenticationException.class, causeChain); if (ase != null) { - if(ase instanceof AccountLockedException){ - return handleOAuth2Exception(new UnauthorizedException(e.getMessage(), e, HttpStatus.LOCKED.value())); - } return handleOAuth2Exception(new UnauthorizedException(e.getMessage(), e)); }