UPDATE: Historian module
All checks were successful
Build and Release / release (push) Successful in 1m20s
All checks were successful
Build and Release / release (push) Successful in 1m20s
This commit is contained in:
@@ -60,3 +60,24 @@ func RequireAllRoles(required ...constants.Role) fiber.Handler {
|
||||
return c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
func ForbidRoles(forbidden ...constants.Role) fiber.Handler {
|
||||
return func(c fiber.Ctx) error {
|
||||
userRoles, err := getRoles(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(userRoles) == 0 {
|
||||
return c.Next()
|
||||
}
|
||||
|
||||
for _, ur := range userRoles {
|
||||
if slices.Contains(forbidden, ur) {
|
||||
return fiber.ErrForbidden
|
||||
}
|
||||
}
|
||||
|
||||
return c.Next()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user