Example #1
0
    private void ConstructMenu()
    {
        List <Artexacta.App.Menu.Menu> theMenu;
        List <Artexacta.App.Menu.Menu> theVisibleMenu;

        theMenu = Artexacta.App.Menu.MenuBLL.MenuBLL.ReadMenuFromXMLConfiguration();

        List <string> theClases = new List <string>();

        // We have to construct the set of "menu classes" for the user.  These will determine what
        // menus the user has access to.

        if (!LoginSecurity.IsUserAuthenticated())
        {
            Response.Redirect("~/Authentication/Login.aspx");
        }

        theClases.Add("CHANGEPASS");

        if (LoginSecurity.IsUserAuthorizedPermission("MANAGE_SECURITY"))
        {
            theClases.Add("SECURITY");
        }

        if (LoginSecurity.IsUserAuthorizedPermission("ADMIN_CLASIFICADORES"))
        {
            theClases.Add("CLASIFICADORES");
        }

        if (LoginSecurity.IsUserAuthorizedPermission("ADMIN_TESTS"))
        {
            theClases.Add("TESTS");
        }

        if (LoginSecurity.IsUserAuthorizedPermission("MANAGE_CATEGORIES"))
        {
            theClases.Add("CATEGORY");
        }

        theVisibleMenu = Artexacta.App.Menu.MenuBLL.MenuBLL.RecursiveConstructionOfVisibleMenus(theMenu, theClases);
        string visibleXML = Artexacta.App.Menu.MenuBLL.MenuBLL.GetMenuXML(theVisibleMenu, 0);

        sideMenu.Text = visibleXML;
        //MainRadMenu.LoadXml(visibleXML);
    }
Example #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            return;
        }

        int userId = 0;

        if (LoginSecurity.IsUserAuthenticated())
        {
            try
            {
                userId = UserBLL.GetUserIdByUsername(HttpContext.Current.User.Identity.Name);
            }
            catch (Exception)
            {
            }
        }
        UserIdHiddenLabel.Text = userId.ToString();
    }
Example #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        log.Debug("############# Master Page starting Page Load #############");
        //BuildFeedbackIframeCode();

        if (!IsPostBack)
        {
            log.Debug("Page is not Postback");

            // Verify the integrity of the system
            Artexacta.App.Utilities.VersionUtilities.VersionUtilities.verifySystemVersionIntegrity();

            log.Debug("Application version is ok");

            /*
             * Perform security validations for the page
             */

            int userID = 0;

            if (LoginSecurity.IsUserAuthenticated())
            {
                try
                {
                    userID = Artexacta.App.User.BLL.UserBLL.GetUserIdByUsername(HttpContext.Current.User.Identity.Name);
                }
                catch (Exception q)
                {
                    log.Error("Failed to get the ID of the current user", q);
                }
            }
            else
            {
                Response.Redirect("~/Authentication/Login.aspx");
            }

            CurrentUserIDHiddenField.Value = userID.ToString();

            bool userIsAdministrator       = LoginSecurity.IsUserAdministrator();
            bool currentPageRoleManagement = IsCurrentPageUserOrRoleManagement();

            if (log.IsDebugEnabled)
            {
                if (userIsAdministrator)
                {
                    log.Debug("Current user IS administrator");
                }
                else
                {
                    log.Debug("Current user IS NOT administrator");
                }

                if (currentPageRoleManagement)
                {
                    log.Debug("Current page IS Role Management");
                }
                else
                {
                    log.Debug("Current page IS NOT Role Management");
                }
            }

            try
            {
                User objUser = UserBLL.GetUserById(userID);
                LoginStatus1.LogoutText = "<i class='zmdi zmdi-run'></i> " + Resources.InitMasterPage.Logout + ", " + objUser.FullName;
            }
            catch (Exception ex)
            {
                log.Error("Error getting user name information", ex);
            }

            if (userIsAdministrator && currentPageRoleManagement)
            {
                // If the current page is the Role Management or the User Management pages then
                // the administrator user is sufficient for access to those pages.
                // Do nothing. We don't perform any further security checks.
                log.Debug("Current user is Admin and page is Role Management.  No further security checks required");
            }
            else
            {
                log.Debug("Determining if user has access to page");

                // Verify that the user has sufficient access permissions for the page.
                if (!IsUserAuthorizedPage())
                {
                    // Transfer the user to a page that tells him that he is not authorized to
                    // see that page.
                    Response.Redirect("~/Authentication/NotAuthorized.aspx");
                }
            }

            // lblUseName.Text = HttpContext.Current.User.Identity.Name;


            LoadMainMenuScript();
            ConstructMenu();
        }
        else
        {
            // Verify that the user has been authenticated.
            LoginSecurity.EnsureUserAuthentication();
        }

        //BuildFeedbackIframeCode();
        //LoadCalendarItems(CurrentUserIDHiddenField.Value);

        log.Debug("############# Master Page ending Page Load #############");
    }