Skip to content
This repository was archived by the owner on May 24, 2023. It is now read-only.
This repository was archived by the owner on May 24, 2023. It is now read-only.

Jwt middleware not using fiber ErrorHandler #40

@Andrflor

Description

@Andrflor

Hello,
I was wondering if it's and intended behavior...
(Code may be better to explain)

The default error handler is written

	if cfg.ErrorHandler == nil {
		cfg.ErrorHandler = func(c *fiber.Ctx, err error) error {
			if err.Error() == "Missing or malformed JWT" {
				return c.Status(fiber.StatusBadRequest).SendString("Missing or malformed JWT")
			} else {
				return c.Status(fiber.StatusUnauthorized).SendString("Invalid or expired JWT")
			}
		}
	}

This way the error is not processed trough the app error handler
Should it not be that way to be processed by any application level error handler by default?

	if cfg.ErrorHandler == nil {
		cfg.ErrorHandler = func(c *fiber.Ctx, err error) error {
			if err.Error() == "Missing or malformed JWT" {
				return fiber.NewError(fiber.StatusBadRequest, "Missing or malformed JWT")
			} else {
				return fiber.NewError(fiber.StatusUnauthorized, "Invalid or expired JWT")
			}
		}
	}

Not sure if i am clear enough 😅

Metadata

Metadata

Assignees

No one assigned

    Labels

    🤔 QuestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions