Ejemplo n.º 1
0
        /// <summary>
        /// Retrieves the path to redirect the user to, if applicable. Otherwise returns String.Empty.
        /// </summary>
        /// <returns>The path to redirect the user to.</returns>
        public string GetRedirectPath()
        {
            string returnPath = String.Empty;

            using (LogGroup logGroup = LogGroup.StartDebug("Retrieving the path to redirect the user to."))
            {
                CheckApplicationPath();

                if (!SkipPage())
                {
                    LogWriter.Debug("Not skipping page.");

                    if (RequiresRestore())
                    {
                        // If the user is an administrator then go to the update ready page
                        if (AuthenticationState.IsAuthenticated && AuthenticationState.UserIsInRole("Administrator"))
                        {
                            LogWriter.Debug("Requires restore. Redirecting administrator to update ready page.");

                            returnPath = ApplicationPath + "/Admin/UpdateReady.html";
                        }
                        else
                        {
                            LogWriter.Debug("Requires restore. Redirecting standard user to maintenance page.");

                            returnPath = ApplicationPath + "/Maintenance.html";
                        }
                    }
                    else if (RequiresImport())
                    {
                        // If import is required then the user must be the administrator and should be sent to the import page.

                        LogWriter.Debug("Requires import. Redirecting to import page.");

                        returnPath = ApplicationPath + "/Admin/Import.aspx";
                    }
                    else if (RequiresInstall())
                    {
                        // If install is required then the user must be the administrator and should be sent to the setup page.

                        LogWriter.Debug("Requires setup. Redirecting to setup page.");

                        returnPath = ApplicationPath + "/Admin/Setup.aspx";
                    }
                }
                else
                {
                    LogWriter.Debug("Skipping page.");
                }

                LogWriter.Debug("Return path: " + returnPath);
            }

            return(returnPath);
        }
Ejemplo n.º 2
0
        static public bool IsInRole(string roleName)
        {
            bool isInRole = false;

            using (LogGroup logGroup = LogGroup.StartDebug("Checking whether the current user is in the specified role."))
            {
                if (!AuthenticationState.IsAuthenticated)
                {
                    isInRole = false;
                }
                else
                {
                    isInRole = AuthenticationState.UserIsInRole(roleName);
                }
            }
            return(isInRole);
        }