public static void ToLogin(Path.Parser path)
 {
     if (path.IsAjax)
     {
         WebServer.Response.Write(Helpers.Elements.Ajax.Alerts.Expiration().ToString());
     }
     else
     {
         WebServer.PleaseTakes.Redirect("/login/");
     }
 }
            public static bool MoreThanOneAvailable(Path.Parser path)
            {
                if (WebServer.PleaseTakes.Application.CurrentInstance.Schools.IsEmpty)
                {
                    throw new PleaseTakesInitialisationException("No schools exist in the permitted list. Contact David.");
                }
                else if (WebServer.PleaseTakes.Application.CurrentInstance.Schools.Count.Equals(1))
                {
                    CreateSessionInstance(path, WebServer.PleaseTakes.Application.CurrentInstance.Schools.OnlySchool);
                    return(false);
                }

                return(true);
            }
 public static void ToSelectionScreen(Path.Parser path, bool showInvalidSchoolIDMessage)
 {
     if (path.IsAjax)
     {
         WebServer.Response.Write(Helpers.Elements.Ajax.Alerts.NoSchoolExpiration().ToString());
     }
     else
     if (showInvalidSchoolIDMessage)
     {
         WebServer.Response.Write("<H1>REQUEST TO SELECTION SCREEN W/ ERROR</H1>");
     }
     else
     {
         WebServer.Response.Write("<H1>REQUEST TO SELECTION SCREEN</H1>");
     }
 }
Exemplo n.º 4
0
        public static void Launch()
        {
            Helpers.InitialisationMethods.ApplicationInstanceCheck();
            Helpers.Path.Parser path = new Helpers.Path.Parser(WebServer.Request["path"]);

            if (!Helpers.InitialisationMethods.RequestSessionExempt(path))
            {
                if (WebServer.PleaseTakes.Session.Exists())
                {
                    Helpers.InitialisationMethods.SessionExists(path);
                }
                else
                {
                    Helpers.InitialisationMethods.NoSessionExists(path);
                }
            }
        }
            public static bool NoDefaultExists(Path.Parser path)
            {
                string defaultValue = WebServer.PleaseTakes.Application.CurrentInstance.Defaults.SchoolID;

                if (!string.IsNullOrEmpty(defaultValue))
                {
                    if (IsValid(defaultValue))
                    {
                        CreateSessionInstance(path, WebServer.PleaseTakes.Application.CurrentInstance.Schools[defaultValue]);
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }

                throw new PleaseTakesInitialisationException("An unrecognised school ID was supplied as the default school.");
            }
        public static void CreateSessionInstance(Path.Parser path, Schools.School school)
        {
            WebServer.PleaseTakes.Session.CreateNewInstance(school);

            if (path.IsEmpty)
            {
                Redirects.ToLogin(path);
            }
            else
            if (path.Contains("dologin"))
            {
                BasicResponses.Login.Action.AttemptLogin();
            }
            else
            {
                WebServer.PleaseTakes.Redirect(path.ToString());
            }

            // This is what is was before the minor modifications (2010-08-12)
            //Redirects.ToLogin(path);
        }
 public static void NoSessionExists(Path.Parser path)
 {
     if (SchoolsInformation.MoreThanOneAvailable(path))
     {
         if (SchoolsInformation.NoDefaultExists(path))
         {
             if (SchoolsInformation.QueryStringBlank())
             {
                 Redirects.ToSelectionScreen(path, false);
             }
             else
             if (SchoolsInformation.QueryStringIsValid())
             {
                 CreateSessionInstance(path, WebServer.PleaseTakes.Application.CurrentInstance.Schools[WebServer.Request["schoolID"]]);
             }
             else
             {
                 Redirects.ToSelectionScreen(path, true);
             }
         }
     }
 }
 public static void SessionExists(Path.Parser path)
 {
     Redirects.Standard(path);
 }
 public static void Standard(Path.Parser path)
 {
     Redirector.Base(path);
 }
Exemplo n.º 10
0
        public static void Base(Path.Parser path)
        {
            if (path.HasNext())
            {
                switch (path.Next())
                {
                // Temporary
                case "test":
                    new BasicResponses.Test(path);
                    break;

                case "home":
                    if (session.IsLoggedIn)
                    {
                        new BasicResponses.Home.Handler(path);
                    }
                    else
                    {
                        throw new NotLoggedInException();
                    }
                    break;

                case "login":
                    if (session.IsLoggedIn)
                    {
                        WebServer.PleaseTakes.Redirect("/home/");
                    }
                    else
                    {
                        BasicResponses.Login.Redirector.Go(path);
                    }
                    break;

                case "logout":
                    if (session.IsLoggedIn)
                    {
                        BasicResponses.Login.Action.LogoutUser();
                    }
                    else
                    {
                        WebServer.PleaseTakes.Redirect("/login/badlogout/");
                    }
                    break;

                case "account":
                    BasicResponses.Account.Redirector.Go(path);
                    break;

                case "cover":
                    if (session.IsLoggedIn)
                    {
                        if (session.Account.IsAdmin)
                        {
                            Cover.Redirector.Go(path);
                        }
                        else
                        {
                            throw new NotAdministrativeException(path.ToString());
                        }
                    }
                    else
                    {
                        throw new NotLoggedInException();
                    }
                    break;

                case "staff":
                    if (session.IsLoggedIn)
                    {
                        if (session.Account.IsAdmin)
                        {
                            UserManagement.Redirector.Go(path);
                        }
                        else
                        {
                            throw new NotAdministrativeException(path.ToString());
                        }
                    }
                    else
                    {
                        throw new NotLoggedInException();
                    }
                    break;

                default:
                    if (session.IsLoggedIn)
                    {
                        WebServer.PleaseTakes.Redirect("/home/");                                       // Perhaps with a message?
                    }
                    else
                    {
                        WebServer.PleaseTakes.Redirect("/login/");
                    }
                    break;
                }
            }
            else
            {
                if (session.IsLoggedIn)
                {
                    WebServer.PleaseTakes.Redirect("/home/");
                }
                else
                {
                    WebServer.PleaseTakes.Redirect("/login/");
                }
            }
        }