mvilrokx
04/11/2024, 5:05 AM200
(empty body), no matter how may errors I return from my handlers. As soon as I remove the session.VerifySession echo'fied middleware, I get the actual errors. It seems as if the session.VerifySession middleware is swallowing the echo error and just returning a 200
instead. Anybody any idea what could be causing this?rp_st
04/11/2024, 5:30 AMrp_st
04/11/2024, 5:30 AMrp_st
04/11/2024, 5:41 AMrp_st
04/11/2024, 5:41 AMmvilrokx
04/12/2024, 2:30 AMfunc CustomVerifySession(options *sessmodels.VerifySessionOptions) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
sessionContainer, err := session.GetSession(c.Request(), c.Response(), options)
if err != nil {
if defaultErrors.As(err, &errors.TryRefreshTokenError{}) {
// This means that the session exists, but the access token
// has expired.
return echo.NewHTTPError(http.StatusUnauthorized, err.Error())
} else if defaultErrors.As(err, &errors.UnauthorizedError{}) {
// This means that the session does not exist anymore.
return echo.NewHTTPError(http.StatusUnauthorized, err.Error())
} else if defaultErrors.As(err, &errors.InvalidClaimError{}) {
// The user is missing some required claim.
// You can pass the missing claims to the frontend and handle it there. Send a 403 to the frontend.
return echo.NewHTTPError(http.StatusForbidden, err.Error())
}
}
if sessionContainer != nil {
c.Set("session", sessionContainer)
}
return next(c)
}
}
}
Basically copied from https://supertokens.com/docs/session/common-customizations/sessions/session-verification-in-api/get-session#building-your-own-custom-middleware and adapted for Echorp_st
04/12/2024, 4:14 AMrp_st
05/01/2024, 11:53 AM