Commit f50afe0d608c52e56b8e1ec9f72c3db996fe00c8
Merge branch 'master_dev' into 'master'
fix: 提交账号过期异常捕获 See merge request yunteng/thingskit!417
Showing
1 changed file
with
4 additions
and
0 deletions
... | ... | @@ -24,6 +24,7 @@ import org.springframework.http.MediaType; |
24 | 24 | import org.springframework.http.ResponseEntity; |
25 | 25 | import org.springframework.lang.Nullable; |
26 | 26 | import org.springframework.security.access.AccessDeniedException; |
27 | +import org.springframework.security.authentication.AccountExpiredException; | |
27 | 28 | import org.springframework.security.authentication.BadCredentialsException; |
28 | 29 | import org.springframework.security.authentication.DisabledException; |
29 | 30 | import org.springframework.security.authentication.LockedException; |
... | ... | @@ -227,6 +228,9 @@ public class ThingsboardErrorResponseHandler extends ResponseEntityExceptionHand |
227 | 228 | } else if (authenticationException instanceof UserPasswordNotValidException) { |
228 | 229 | UserPasswordNotValidException expiredException = (UserPasswordNotValidException) authenticationException; |
229 | 230 | JacksonUtil.writeValue(response.getWriter(), ThingsboardCredentialsViolationResponse.of(expiredException.getMessage())); |
231 | + }else if(authenticationException instanceof AccountExpiredException) { | |
232 | + AccountExpiredException expiredException = (AccountExpiredException) authenticationException; | |
233 | + JacksonUtil.writeValue(response.getWriter(), ThingsboardCredentialsExpiredResponse.of(expiredException.getMessage(),ThingsboardErrorCode.AUTHENTICATION, HttpStatus.FORBIDDEN)); | |
230 | 234 | } else { |
231 | 235 | JacksonUtil.writeValue(response.getWriter(), ThingsboardErrorResponse.of(ErrorMessage.AUTHENTICATION_METHOD_NOT_SUPPORTED.getMessage(), ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED)); |
232 | 236 | } | ... | ... |