Skip to content

Commit

Permalink
chore: respond with 'bad request' when token claims are invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoern-m committed Dec 30, 2024
1 parent 11b5da0 commit b9c6d27
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backend/handler/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (h *SessionHandler) ValidateSession(c echo.Context) error {

claims, err := dto.GetClaimsFromToken(token)
if err != nil {
return c.JSON(http.StatusOK, dto.ValidateSessionResponse{IsValid: false})
return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("failed to parse token claims: %w", err))
}

sessionModel, err := h.persister.GetSessionPersister().Get(claims.SessionID)
Expand Down Expand Up @@ -96,7 +96,7 @@ func (h *SessionHandler) ValidateSessionFromBody(c echo.Context) error {

claims, err := dto.GetClaimsFromToken(token)
if err != nil {
return c.JSON(http.StatusOK, dto.ValidateSessionResponse{IsValid: false})
return echo.NewHTTPError(http.StatusBadRequest, fmt.Errorf("failed to parse token claims: %w", err))
}

sessionModel, err := h.persister.GetSessionPersister().Get(claims.SessionID)
Expand Down

0 comments on commit b9c6d27

Please sign in to comment.