migrate to fiber
This commit is contained in:
@@ -4,19 +4,19 @@ import (
|
||||
"filething/models"
|
||||
"net/http"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
func AdminMiddleware() echo.MiddlewareFunc {
|
||||
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
user := c.Get("user").(*models.User)
|
||||
func AdminMiddleware(db *bun.DB) func(c fiber.Ctx) error {
|
||||
return func(c fiber.Ctx) error {
|
||||
user := c.Locals("user").(*models.User)
|
||||
|
||||
if !user.Admin {
|
||||
return echo.NewHTTPError(http.StatusForbidden, "You are not an administrator")
|
||||
}
|
||||
|
||||
return next(c)
|
||||
if !user.Admin {
|
||||
return echo.NewHTTPError(http.StatusForbidden, "You are not an administrator")
|
||||
}
|
||||
|
||||
return c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user