forked from ebhomengo/niki
24 lines
558 B
Go
24 lines
558 B
Go
package middleware
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
|
authservice "git.gocasts.ir/ebhomengo/niki/service/auth"
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
// nolint
|
|
func TokenSeed(cfg authservice.Service) echo.MiddlewareFunc {
|
|
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
|
return func(c echo.Context) error {
|
|
token := c.Request().Header.Get("token")
|
|
if token != cfg.Config.SeedToken {
|
|
return c.JSON(http.StatusForbidden, echo.Map{"message": errmsg.ErrorMsgUserNotAllowed})
|
|
}
|
|
|
|
return next(c)
|
|
}
|
|
}
|
|
}
|