package middlewares import ( "backend/app/consts" "backend/app/errorx" "github.com/gofiber/fiber/v3" ) func (f *Middlewares) ParseJWT(c fiber.Ctx) error { token := c.Cookies(consts.TokenTypeUser.String()) if token == "" { token = c.Query("token") if token == "" { return c.Next() } } claim, err := f.jwt.Parse(token) if err != nil { c.ClearCookie(consts.TokenTypeUser.String()) return errorx.Unauthorized } c.Locals("claim", claim) return c.Next() }