This commit is contained in:
41666 2025-04-05 22:02:17 -07:00
parent 8c8cbfd7dd
commit 41d48bf60a
28 changed files with 434 additions and 7 deletions

View file

@ -0,0 +1,20 @@
package authmiddleware
import (
"net/http"
"git.sapphic.engineer/roleypoly/v4/types"
"github.com/gofiber/fiber/v3"
)
func MustHavePermission(perm Permission) func(fiber.Ctx) error {
return func(c fiber.Ctx) error {
sess := SessionFrom(c)
if sess.Permissions >= perm {
return c.Next()
}
return types.NewAPIError(http.StatusForbidden, "no sorry").Send(c)
}
}