20 lines
378 B
Go
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)
|
|
}
|
|
}
|