|
|
@ -32,6 +32,7 @@ import org.springframework.http.ResponseEntity; |
|
|
import org.springframework.lang.Nullable; |
|
|
import org.springframework.lang.Nullable; |
|
|
import org.springframework.security.access.AccessDeniedException; |
|
|
import org.springframework.security.access.AccessDeniedException; |
|
|
import org.springframework.security.authentication.BadCredentialsException; |
|
|
import org.springframework.security.authentication.BadCredentialsException; |
|
|
|
|
|
import org.springframework.security.authentication.CredentialsExpiredException; |
|
|
import org.springframework.security.authentication.DisabledException; |
|
|
import org.springframework.security.authentication.DisabledException; |
|
|
import org.springframework.security.authentication.LockedException; |
|
|
import org.springframework.security.authentication.LockedException; |
|
|
import org.springframework.security.core.AuthenticationException; |
|
|
import org.springframework.security.core.AuthenticationException; |
|
|
@ -242,6 +243,8 @@ public class ThingsboardErrorResponseHandler extends ResponseEntityExceptionHand |
|
|
JacksonUtil.writeValue(response.getWriter(), ThingsboardCredentialsExpiredResponse.of(expiredException.getMessage(), resetToken)); |
|
|
JacksonUtil.writeValue(response.getWriter(), ThingsboardCredentialsExpiredResponse.of(expiredException.getMessage(), resetToken)); |
|
|
} else if (authenticationException instanceof UserPasswordNotValidException expiredException) { |
|
|
} else if (authenticationException instanceof UserPasswordNotValidException expiredException) { |
|
|
JacksonUtil.writeValue(response.getWriter(), ThingsboardCredentialsViolationResponse.of(expiredException.getMessage())); |
|
|
JacksonUtil.writeValue(response.getWriter(), ThingsboardCredentialsViolationResponse.of(expiredException.getMessage())); |
|
|
|
|
|
} else if (authenticationException instanceof CredentialsExpiredException credentialsExpiredException) { |
|
|
|
|
|
JacksonUtil.writeValue(response.getWriter(), ThingsboardCredentialsViolationResponse.of(credentialsExpiredException.getMessage(), ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED)); |
|
|
} else { |
|
|
} else { |
|
|
JacksonUtil.writeValue(response.getWriter(), ThingsboardErrorResponse.of("Authentication failed", ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED)); |
|
|
JacksonUtil.writeValue(response.getWriter(), ThingsboardErrorResponse.of("Authentication failed", ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED)); |
|
|
} |
|
|
} |
|
|
|