mirror of
https://github.com/lzh-1625/go_process_manager.git
synced 2025-09-27 04:16:04 +08:00
19 lines
425 B
Go
19 lines
425 B
Go
package middle
|
|
|
|
import (
|
|
"github.com/lzh-1625/go_process_manager/internal/app/eum"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func RolePermission(needPermission eum.Role) func(ctx *gin.Context) {
|
|
return func(ctx *gin.Context) {
|
|
if v, ok := ctx.Get(eum.CtxRole); !ok || v.(eum.Role) > needPermission {
|
|
rErr(ctx, -1, "Insufficient permissions; please check your access rights!", nil)
|
|
ctx.Abort()
|
|
return
|
|
}
|
|
ctx.Next()
|
|
}
|
|
}
|