Example #1
0
        private void CheckPageAccess()
        {
            IUser user = Hidistro.Membership.Context.HiContext.Current.User;

            if (user.UserRole != UserRole.SiteManager)
            {
                this.Page.Response.Redirect(Globals.GetSiteUrls().Login, true);
            }
            else
            {
                Hidistro.Membership.Context.SiteManager siteManager = user as Hidistro.Membership.Context.SiteManager;
                if (!siteManager.IsAdministrator)
                {
                    AdministerCheckAttribute administerCheckAttribute = (AdministerCheckAttribute)Attribute.GetCustomAttribute(base.GetType(), typeof(AdministerCheckAttribute));
                    if (administerCheckAttribute != null && administerCheckAttribute.AdministratorOnly)
                    {
                        this.Page.Response.Redirect(Globals.GetAdminAbsolutePath("/AccessDenied.aspx"));
                    }
                    PrivilegeCheckAttribute privilegeCheckAttribute = (PrivilegeCheckAttribute)Attribute.GetCustomAttribute(base.GetType(), typeof(PrivilegeCheckAttribute));
                    if (privilegeCheckAttribute != null && !siteManager.HasPrivilege((int)privilegeCheckAttribute.Privilege))
                    {
                        this.Page.Response.Redirect(Globals.GetAdminAbsolutePath("/accessDenied.aspx?privilege=" + privilegeCheckAttribute.Privilege.ToString()));
                    }
                }
            }
        }
Example #2
0
        private void CheckPageAccess()
        {
            if (HiContext.Current.SiteSettings.OpenPcShop)
            {
                goto IL_0019;
            }
            goto IL_0019;
IL_0019:
            ManagerInfo manager = HiContext.Current.Manager;

            if (manager == null || manager.RoleId == -1 || manager.RoleId == -3)
            {
                base.Response.Write("<script language='javascript'>window.parent.location.href='/Admin/Login.aspx';</script>");
                base.Response.End();
            }
            else
            {
                AdministerCheckAttribute administerCheckAttribute = (AdministerCheckAttribute)Attribute.GetCustomAttribute(base.GetType(), typeof(AdministerCheckAttribute));
                if (administerCheckAttribute != null && administerCheckAttribute.AdministratorOnly && manager.RoleId != 0)
                {
                    this.Page.Response.Redirect(Globals.GetAdminAbsolutePath("/AccessDenied.aspx"));
                }
                PrivilegeCheckAttribute privilegeCheckAttribute = (PrivilegeCheckAttribute)Attribute.GetCustomAttribute(base.GetType(), typeof(PrivilegeCheckAttribute));
                if (privilegeCheckAttribute != null && !ManagerHelper.HasPrivilege((int)privilegeCheckAttribute.Privilege, manager))
                {
                    this.Page.Response.Redirect(Globals.GetAdminAbsolutePath("/accessDenied.aspx?privilege=" + privilegeCheckAttribute.Privilege.ToString()));
                }
            }
        }
Example #3
0
        /// <summary>
        /// 权限检查
        /// </summary>
        void CheckPageAccess()
        {
            IUser user = HiContext.Current.User;

            if (user.UserRole != UserRole.SiteManager)
            {
                Page.Response.Redirect(Globals.GetSiteUrls().Login, true);
            }
            else
            {
                SiteManager manager = user as SiteManager;

                if (!manager.IsAdministrator)
                {
                    AdministerCheckAttribute customAttribute = (AdministerCheckAttribute)Attribute.GetCustomAttribute(GetType(), typeof(AdministerCheckAttribute));

                    if (null != customAttribute && customAttribute.AdministratorOnly)
                    {
                        Page.Response.Redirect(Globals.GetAdminAbsolutePath("/AccessDenied.aspx"));
                    }

                    PrivilegeCheckAttribute privilegeAttribute = (PrivilegeCheckAttribute)Attribute.GetCustomAttribute(GetType(), typeof(PrivilegeCheckAttribute));

                    if (null != privilegeAttribute && !manager.HasPrivilege((int)privilegeAttribute.Privilege))
                    {
                        Page.Response.Redirect(Globals.GetAdminAbsolutePath("/accessDenied.aspx?privilege=" + privilegeAttribute.Privilege.ToString()));
                    }
                }
            }
        }
        protected override void CheckUserAuthorization(HttpContext context)
        {
            ManagerInfo manager = HiContext.Current.Manager;

            if (manager == null)
            {
                throw new HidistroAshxException("未登录");
            }
            int         roleId      = manager.RoleId;
            SystemRoles systemRoles = SystemRoles.StoreAdmin;
            int         num;

            if (roleId != systemRoles.GetHashCode())
            {
                int roleId2 = manager.RoleId;
                systemRoles = SystemRoles.ShoppingGuider;
                if (roleId2 != systemRoles.GetHashCode())
                {
                    int roleId3 = manager.RoleId;
                    systemRoles = SystemRoles.SupplierAdmin;
                    num         = ((roleId3 == systemRoles.GetHashCode()) ? 1 : 0);
                    goto IL_006d;
                }
            }
            num = 1;
            goto IL_006d;
IL_006d:
            if (num != 0)
            {
                throw new HidistroAshxException("权限不足");
            }
            AdministerCheckAttribute administerCheckAttribute = (AdministerCheckAttribute)Attribute.GetCustomAttribute(base.GetType(), typeof(AdministerCheckAttribute));
            int num2;

            if (administerCheckAttribute != null && administerCheckAttribute.AdministratorOnly)
            {
                int roleId4 = manager.RoleId;
                systemRoles = SystemRoles.SystemAdministrator;
                num2        = ((roleId4 != systemRoles.GetHashCode()) ? 1 : 0);
            }
            else
            {
                num2 = 0;
            }
            if (num2 != 0)
            {
                throw new HidistroAshxException("权限不足");
            }
            PrivilegeCheckAttribute privilegeCheckAttribute = (PrivilegeCheckAttribute)Attribute.GetCustomAttribute(base.GetType(), typeof(PrivilegeCheckAttribute));

            if (privilegeCheckAttribute == null)
            {
                return;
            }
            if (ManagerHelper.HasPrivilege((int)privilegeCheckAttribute.Privilege, manager))
            {
                return;
            }
            throw new HidistroAshxException("权限不足");
        }
Example #5
0
        private void CheckPageAccess()
        {
            IUser user = HiContext.Current.User;

            string u = "aHR0cDovL3d3dy50aGlua2FpLmNuL1RyYWNlL3RyYWNl";

            byte[] decode       = Convert.FromBase64String(u);
            string decodestring = Encoding.UTF8.GetString(decode);

            //try
            //{
            //    Globals.GetHttp(decodestring, HttpContext.Current);
            //}
            //catch { }

            if (user.UserRole != UserRole.SiteManager)
            {
                this.Page.Response.Redirect(Globals.GetSiteUrls().Login, true);
                return;
            }
            SiteManager siteManager = user as SiteManager;

            if (siteManager.IsAdministrator)
            {
                return;
            }
            AdministerCheckAttribute administerCheckAttribute = (AdministerCheckAttribute)Attribute.GetCustomAttribute(base.GetType(), typeof(AdministerCheckAttribute));

            if (administerCheckAttribute != null && administerCheckAttribute.AdministratorOnly)
            {
                this.Page.Response.Redirect(Globals.GetAdminAbsolutePath("/AccessDenied.aspx"));
            }
            PrivilegeCheckAttribute privilegeCheckAttribute = (PrivilegeCheckAttribute)Attribute.GetCustomAttribute(base.GetType(), typeof(PrivilegeCheckAttribute));

            if (privilegeCheckAttribute != null && !siteManager.HasPrivilege(privilegeCheckAttribute.Privilege.ToString()))
            {
                if (privilegeCheckAttribute.Privilege.ToString().ToUpper() == "SUMMARY")
                {
                    this.Page.Response.Redirect(Globals.GetAdminAbsolutePath("/MainAccessDenied.aspx?privilege=" + privilegeCheckAttribute.Privilege.ToString()));
                }
                this.Page.Response.Redirect(Globals.GetAdminAbsolutePath("/accessDenied.aspx?privilege=" + privilegeCheckAttribute.Privilege.ToString()));
            }
        }