Showing
1 changed file
with
4 additions
and
0 deletions
@@ -24,6 +24,7 @@ import org.springframework.http.MediaType; | @@ -24,6 +24,7 @@ import org.springframework.http.MediaType; | ||
24 | import org.springframework.http.ResponseEntity; | 24 | import org.springframework.http.ResponseEntity; |
25 | import org.springframework.lang.Nullable; | 25 | import org.springframework.lang.Nullable; |
26 | import org.springframework.security.access.AccessDeniedException; | 26 | import org.springframework.security.access.AccessDeniedException; |
27 | +import org.springframework.security.authentication.AccountExpiredException; | ||
27 | import org.springframework.security.authentication.BadCredentialsException; | 28 | import org.springframework.security.authentication.BadCredentialsException; |
28 | import org.springframework.security.authentication.DisabledException; | 29 | import org.springframework.security.authentication.DisabledException; |
29 | import org.springframework.security.authentication.LockedException; | 30 | import org.springframework.security.authentication.LockedException; |
@@ -227,6 +228,9 @@ public class ThingsboardErrorResponseHandler extends ResponseEntityExceptionHand | @@ -227,6 +228,9 @@ public class ThingsboardErrorResponseHandler extends ResponseEntityExceptionHand | ||
227 | } else if (authenticationException instanceof UserPasswordNotValidException) { | 228 | } else if (authenticationException instanceof UserPasswordNotValidException) { |
228 | UserPasswordNotValidException expiredException = (UserPasswordNotValidException) authenticationException; | 229 | UserPasswordNotValidException expiredException = (UserPasswordNotValidException) authenticationException; |
229 | JacksonUtil.writeValue(response.getWriter(), ThingsboardCredentialsViolationResponse.of(expiredException.getMessage())); | 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 | } else { | 234 | } else { |
231 | JacksonUtil.writeValue(response.getWriter(), ThingsboardErrorResponse.of(ErrorMessage.AUTHENTICATION_METHOD_NOT_SUPPORTED.getMessage(), ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED)); | 235 | JacksonUtil.writeValue(response.getWriter(), ThingsboardErrorResponse.of(ErrorMessage.AUTHENTICATION_METHOD_NOT_SUPPORTED.getMessage(), ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED)); |
232 | } | 236 | } |