v4/auth/authmiddleware/must.go
2025-04-05 22:02:17 -07:00

20 lines
378 B
Go

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)
}
}