示例#1
0
        /// <summary>
        /// 是否具有设置吧管理员的权限
        /// </summary>
        /// <param name="authorizer"></param>
        /// <param name="barSection"></param>
        /// <returns></returns>
        public static bool BarSection_SetManager(this Authorizer authorizer, BarSection barSection)
        {
            if (barSection == null)
            {
                return(false);
            }

            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(false);
            }

            //吧主
            if (barSection.UserId == currentUser.UserId)
            {
                return(true);
            }



            if (authorizer.IsAdministrator(BarConfig.Instance().ApplicationId))
            {
                return(true);
            }

            return(false);
        }
示例#2
0
        /// <summary>
        /// 是否具有编辑BarPost的权限
        /// </summary>
        /// <param name="post"></param>
        /// <returns></returns>
        public static bool BarPost_Edit(this Authorizer authorizer, BarPost post)
        {
            if (authorizer.IsAdministrator(BarConfig.Instance().ApplicationId))
            {
                return(true);
            }

            if (post == null)
            {
                return(false);
            }

            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(false);
            }
            if (post.UserId == currentUser.UserId)
            {
                return(true);
            }
            BarSectionService barSectionService = new BarSectionService();

            if (authorizer.BarSection_Manage(barSectionService.Get(post.SectionId)))
            {
                return(true);
            }

            return(false);
        }
示例#3
0
        /// <summary>
        /// 是否具有创建BarSection的权限
        /// </summary>
        /// <returns></returns>
        public static bool BarSection_Create(this Authorizer authorizer)
        {
            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(false);
            }

            if (authorizer.IsAdministrator(BarConfig.Instance().ApplicationId))
            {
                return(true);
            }

            IBarSettingsManager barSettingsManager = DIContainer.Resolve <IBarSettingsManager>();
            BarSettings         barSetting         = barSettingsManager.Get();

            if (!barSetting.EnableUserCreateSection)
            {
                return(false);
            }
            if (currentUser.Rank < barSetting.UserRankOfCreateSection)
            {
                return(false);
            }
            return(true);
        }
示例#4
0
        /// <summary>
        /// 是否具有管理BarSection的权限
        /// </summary>
        /// <param name="barSection"></param>
        /// <returns></returns>
        public static bool BarSection_Manage(this Authorizer authorizer, BarSection barSection)
        {
            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(false);
            }

            if (barSection == null)
            {
                return(false);
            }

            if (barSection.AuditStatus == AuditStatus.Success)
            {
                //吧主
                if (barSection.UserId == currentUser.UserId)
                {
                    return(true);
                }

                //吧管理员
                if (authorizer.AuthorizationService.IsTenantManager(currentUser, barSection.TenantTypeId, barSection.SectionId))
                {
                    return(true);
                }
            }

            TenantType tenantType    = new TenantTypeService().Get(barSection.TenantTypeId);
            int        applicationId = BarConfig.Instance().ApplicationId;

            if (tenantType != null)
            {
                applicationId = tenantType.ApplicationId;
            }
            if (authorizer.IsAdministrator(applicationId))
            {
                return(true);
            }

            return(false);
        }
示例#5
0
        /// <summary>
        /// 是否具有删除BarSection的权限
        /// </summary>
        /// <param name="barSection"></param>
        /// <returns></returns>
        public static bool BarSection_Delete(this Authorizer authorizer)
        {
            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(false);
            }

            if (authorizer.IsAdministrator(BarConfig.Instance().ApplicationId))
            {
                return(true);
            }



            ////吧主
            //if (barSection.UserId == currentUser.UserId)
            //    return true;

            return(false);
        }