...
|
...
|
@@ -108,7 +108,7 @@ public class ThingsboardErrorResponseHandler extends ResponseEntityExceptionHand |
108
|
108
|
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
109
|
109
|
response.setStatus(HttpStatus.FORBIDDEN.value());
|
110
|
110
|
mapper.writeValue(response.getWriter(),
|
111
|
|
- ThingsboardErrorResponse.of("You don't have permission to perform this operation!",
|
|
111
|
+ ThingsboardErrorResponse.of(ErrorMessage.NOT_HAVE_PERMISSION.getMessage(),
|
112
|
112
|
ThingsboardErrorCode.PERMISSION_DENIED, HttpStatus.FORBIDDEN));
|
113
|
113
|
}
|
114
|
114
|
}
|
...
|
...
|
@@ -188,7 +188,7 @@ public class ThingsboardErrorResponseHandler extends ResponseEntityExceptionHand |
188
|
188
|
private void handleAccessDeniedException(HttpServletResponse response) throws IOException {
|
189
|
189
|
response.setStatus(HttpStatus.FORBIDDEN.value());
|
190
|
190
|
mapper.writeValue(response.getWriter(),
|
191
|
|
- ThingsboardErrorResponse.of("You don't have permission to perform this operation!",
|
|
191
|
+ ThingsboardErrorResponse.of(ErrorMessage.NOT_HAVE_PERMISSION.getMessage(),
|
192
|
192
|
ThingsboardErrorCode.PERMISSION_DENIED, HttpStatus.FORBIDDEN));
|
193
|
193
|
|
194
|
194
|
}
|
...
|
...
|
@@ -196,13 +196,13 @@ public class ThingsboardErrorResponseHandler extends ResponseEntityExceptionHand |
196
|
196
|
private void handleAuthenticationException(AuthenticationException authenticationException, HttpServletResponse response) throws IOException {
|
197
|
197
|
response.setStatus(HttpStatus.UNAUTHORIZED.value());
|
198
|
198
|
if (authenticationException instanceof BadCredentialsException || authenticationException instanceof UsernameNotFoundException) {
|
199
|
|
- mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of("Invalid username or password", ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
|
|
199
|
+ mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of(ErrorMessage.USERNAME_PASSWORD_INCORRECT.getMessage(), ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
|
200
|
200
|
} else if (authenticationException instanceof DisabledException) {
|
201
|
|
- mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of("User account is not active", ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
|
|
201
|
+ mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of(ErrorMessage.ACCOUNT_IS_NOT_ACTIVE.getMessage(), ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
|
202
|
202
|
} else if (authenticationException instanceof LockedException) {
|
203
|
203
|
mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of(ErrorMessage.ACCOUNT_LOCKED.getMessage(), ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
|
204
|
204
|
} else if (authenticationException instanceof JwtExpiredTokenException) {
|
205
|
|
- mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of("Token has expired", ThingsboardErrorCode.JWT_TOKEN_EXPIRED, HttpStatus.UNAUTHORIZED));
|
|
205
|
+ mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of(ErrorMessage.TOKEN_EXPIRED.getMessage(), ThingsboardErrorCode.JWT_TOKEN_EXPIRED, HttpStatus.UNAUTHORIZED));
|
206
|
206
|
} else if (authenticationException instanceof AuthMethodNotSupportedException) {
|
207
|
207
|
mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of(authenticationException.getMessage(), ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
|
208
|
208
|
} else if (authenticationException instanceof UserPasswordExpiredException) {
|
...
|
...
|
@@ -214,7 +214,7 @@ public class ThingsboardErrorResponseHandler extends ResponseEntityExceptionHand |
214
|
214
|
mapper.writeValue(response.getWriter(), ThingsboardCredentialsExpiredResponse.of(expiredException.getMessage(),ThingsboardErrorCode.AUTHENTICATION, HttpStatus.FORBIDDEN));
|
215
|
215
|
}
|
216
|
216
|
else {
|
217
|
|
- mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of("Authentication failed", ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
|
|
217
|
+ mapper.writeValue(response.getWriter(), ThingsboardErrorResponse.of(ErrorMessage.AUTHENTICATION_METHOD_NOT_SUPPORTED.getMessage(), ThingsboardErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
|
218
|
218
|
}
|
219
|
219
|
}
|
220
|
220
|
|
...
|
...
|
|