public async Task <object> GetOperatorInfo()
        {
            var theInfo     = _operator.Property;
            var permissions = await _permissionBus.GetUserPermissionValuesAsync(_operator.UserId);

            var resObj = new
            {
                UserInfo    = theInfo,
                Permissions = permissions
            };

            return(resObj);
        }
Esempio n. 2
0
        /// <summary>
        /// Action执行之前执行
        /// </summary>
        /// <param name="context">过滤器上下文</param>
        public async override Task OnActionExecuting(ActionExecutingContext context)
        {
            if (context.ContainsFilter <NoApiPermissionAttribute>())
            {
                return;
            }

            IPermissionBusiness permissionBus = AutofacHelper.GetScopeService <IPermissionBusiness>();
            var permissions = await permissionBus.GetUserPermissionValuesAsync(Operator.UserId);

            if (!permissions.Contains(_permissionValue))
            {
                context.Result = Error("权限不足!");
            }
        }
Esempio n. 3
0
        public async Task <object> GetOperatorInfo()
        {
            var theInfo = await _userBus.GetTheDataAsync(_operator.UserId);

            var permissions = await _permissionBus.GetUserPermissionValuesAsync(_operator.UserId);

            var projectList = await _mini_project_userBusiness.GetUserProjectListAsync(_operator.UserId);

            var resObj = new
            {
                UserInfo    = theInfo,
                Permissions = permissions,
                ProjectList = projectList
            };

            return(resObj);
        }
        /// <summary>
        /// Action执行之前执行
        /// </summary>
        /// <param name="context">过滤器上下文</param>
        public async override Task OnActionExecuting(ActionExecutingContext context)
        {
            if (context.ContainsFilter <NoApiPermissionAttribute>())
            {
                return;
            }
            IServiceProvider    serviceProvider = context.HttpContext.RequestServices;
            IPermissionBusiness _permissionBus  = serviceProvider.GetService <IPermissionBusiness>();
            IOperator           _operator       = serviceProvider.GetService <IOperator>();

            var permissions = await _permissionBus.GetUserPermissionValuesAsync(_operator.UserId);

            if (!permissions.Contains(_permissionValue))
            {
                context.Result = Error("权限不足!");
            }
        }