package middleware import ( "github.com/gin-gonic/gin" "wireguard-dashboard/constant" "wireguard-dashboard/model/entity" "wireguard-dashboard/utils" ) // Permission // @description: 权限验证,一些操作权限 // @return gin.HandlerFunc func Permission() gin.HandlerFunc { return func(c *gin.Context) { userInfo, ok := c.Get("user") if !ok { utils.GinResponse(c).AuthorizationFailed() c.Abort() return } if userInfo.(*entity.User).IsAdmin != constant.SuperAdmin { utils.GinResponse(c).FailedWithMsg("你暂无权限操作") c.Abort() return } c.Next() } }