Return bad request instead of unauthorized

This commit is contained in:
2025-01-30 18:40:58 +01:00
parent 5972129cb4
commit 29c7a0b93b
2 changed files with 12 additions and 2 deletions

View File

@ -63,8 +63,8 @@ public class JwtRequestFilter extends OncePerRequestFilter {
filterChain.doFilter(request, response);
} catch (Exception e) {
response.setContentType("application/json");
response.setStatus(HttpStatus.UNAUTHORIZED.value());
response.getWriter().write(objectMapper.writeValueAsString(new ErrorResponse("Couldn't authenticate", HttpStatus.UNAUTHORIZED.value())));
response.setStatus(HttpStatus.BAD_REQUEST.value());
response.getWriter().write(objectMapper.writeValueAsString(new ErrorResponse("Couldn't authenticate", HttpStatus.BAD_REQUEST.value())));
}
}