Update Rest API #33
@@ -1,6 +1,6 @@
|
|||||||
package com.faf223.expensetrackerfaf.config;
|
package com.faf223.expensetrackerfaf.config;
|
||||||
|
|
||||||
import com.faf223.expensetrackerfaf.controller.auth.ErrorResponse;
|
import com.faf223.expensetrackerfaf.util.errors.ErrorResponse;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.jsonwebtoken.ExpiredJwtException;
|
import io.jsonwebtoken.ExpiredJwtException;
|
||||||
import jakarta.servlet.FilterChain;
|
import jakarta.servlet.FilterChain;
|
||||||
@@ -61,7 +61,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
|||||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||||
response.setContentType("application/json");
|
response.setContentType("application/json");
|
||||||
|
|
||||||
ErrorResponse errorResponse = new ErrorResponse("TokenExpired", "Your session has expired. Please log in again.");
|
ErrorResponse errorResponse = new ErrorResponse("Your session has expired. Please log in again.");
|
||||||
ObjectMapper objectMapper = new ObjectMapper(); // You may need to import ObjectMapper
|
ObjectMapper objectMapper = new ObjectMapper(); // You may need to import ObjectMapper
|
||||||
response.getWriter().write(objectMapper.writeValueAsString(errorResponse));
|
response.getWriter().write(objectMapper.writeValueAsString(errorResponse));
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.faf223.expensetrackerfaf.controller.auth;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public class ErrorResponse {
|
|
||||||
private String error;
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
public ErrorResponse(String error, String message) {
|
|
||||||
this.error = error;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user