Пример #1
0
        private void Application_BeginRequest(object sender, System.EventArgs e)
        {
            HttpApplication app     = ((HttpApplication)(sender));
            HttpContext     context = app.Context;
            string          r       = context.Request.RawUrl;

            // get the user
            System.Web.HttpContext.Current.User = SFGlobal.FetchUser();

            if (!cs.IsExcluded(r))                      // page isn't excluded
            {
                if (r.IndexOf(rqcs.AdminDirectory) > 0) // is in the 'admin' directory
                {
                    bool b = false;
                    foreach (string role in SFGlobal.CurrentUser.Roles)
                    {
                        if (SFGlobal.CurrentUser.IsRoleCMS(role, NodeFactory.RootNode))
                        {
                            b = true;
                        }
                    }

                    if (!b)
                    {
                        SFGlobal.RedirectToLogin();
                    }

                    /*
                     * if (!SFGlobal.CurrentUser.IsUserCMS())
                     * {
                     *      SFGlobal.RedirectToLogin();
                     * }
                     */
                }
                else                 // process normally
                {
                    if (context.Items["currentNode"] == null)
                    {
                        throw new Exception("currentNode is null and page isn't excluded from url processing:");
                        //context.Response.End();
                    }

                    if (!SFGlobal.CheckUserNodePermission(Permission.View))                     // check to see if the user has view permissions
                    {
                        //context.Response.Write("process");
                        //context.Response.End();
                        SFGlobal.RedirectToLogin();
                    }
                }
            }
        }