roles
This commit is contained in:
parent
8c8cbfd7dd
commit
41d48bf60a
28 changed files with 434 additions and 7 deletions
20
auth/authmiddleware/must.go
Normal file
20
auth/authmiddleware/must.go
Normal 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)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue