Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         SessionUtil.SavaModuleTag("ChangeMyPwd");
         if (SessionUtil.GetStaffSession().IsInnerUser == 0)
         {
             PermissionUtil.SaveGrantPermissionsToSession();
             if (!PermissionUtil.HasGrantPermission("rights_browse"))
             {
                 throw new ModuleSecurityException("无权限访问此模块。");
             }
         }
     }
     catch (MissSessionException)
     {
         ClientScript.RegisterClientScriptBlock(this.GetType(), "reload",
                                                "<script type=\"text/javascript\">parent.location='../../Default.aspx';</script>");
     }
     catch (ModuleSecurityException)
     {
         Response.Redirect("../../Frameset/Welcome.aspx");
     }
     catch (Exception ex)
     {
         log.Error(null, ex);
         throw;
     }
 }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Cache.SetCacheability(HttpCacheability.NoCache);

        try
        {
            SessionUtil.SavaModuleTag("StaffMgr");
            if (SessionUtil.GetStaffSession().IsInnerUser == 0)
            {
                PermissionUtil.SaveGrantPermissionsToSession();
                if (!PermissionUtil.HasGrantPermission("rights_browse"))
                {
                    throw new ModuleSecurityException("无权限访问此模块。");
                }
                if (!PermissionUtil.HasGrantPermission("rights_add"))
                {
                    btnNew.Style.Add("display", "none");
                }
                if (!PermissionUtil.HasGrantPermission("rights_edit"))
                {
                    btnEdit.Style.Add("display", "none");
                    btnEditPassword.Style.Add("display", "none");
                }
                if (!PermissionUtil.HasGrantPermission("rights_move"))
                {
                    btnMove.Style.Add("display", "none");
                }
                if (!PermissionUtil.HasGrantPermission("rights_accredit"))
                {
                    btnRole.Style.Add("display", "none");
                    btnPermission.Style.Add("display", "none");
                }
                if (!PermissionUtil.HasGrantPermission("rights_delete"))
                {
                    btnDelete.Style.Add("display", "none");
                }
            }

            LoadDepartmentTree(tvDepartments.Nodes[0], null);
        }
        catch (MissSessionException)
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "reload",
                                                   "<script type=\"text/javascript\">parent.location='../../Default.aspx';</script>");
        }
        catch (ModuleSecurityException)
        {
            Response.Redirect("../../Frameset/Welcome.aspx");
        }
        catch (Exception ex)
        {
            log.Error(null, ex);
            throw;
        }
    }
Ejemplo n.º 3
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            //获取当前的Action
            string currentAction     = filterContext.RouteData.Values["action"].ToString();
            string currentController = filterContext.RouteData.Values["controller"].ToString();

            //当前action不是 logon 则判断session session为空 跳转到登录页
            if (SessionUtil.GetStaffSession() == null)
            {
                string requestWith = filterContext.HttpContext.Request.Headers["X-Requested-With"];
                //如果为 ajax 请求
                if (!string.IsNullOrEmpty(requestWith) && requestWith.ToLower() == "xmlhttprequest")
                {
                    var contentResult = new ContentResult();
                    contentResult.Content = "登录超时,请刷新页面";
                    filterContext.Result  = contentResult;
                }
                else
                {
                    if (currentController.ToLower() == "admin")
                    {
                        filterContext.Result = new RedirectResult("/");
                    }
                    else
                    {
                        var contentResult = new ContentResult();
                        contentResult.Content = "<script type='text/javascript'>parent.location.href='/Logon/Login';</script>";
                        filterContext.Result  = contentResult;
                    }
                }
            }
            else if (SessionUtil.GetStaffSession() != null)
            {
                //保存当前的 moduleTag
                //action 需与 后台模块添加时的 moduletag 保持一致
                SessionUtil.SavaModuleTag(currentAction);
                //保存当前用户的 权限信息
                PermissionUtil.SaveGrantPermissionsToSession();
            }

            base.OnActionExecuting(filterContext);
        }