Esempio n. 1
0
        public void MapPinningRule(WebMap webMap, string registeredSectionUri = null)
        {
            var sectionUri = registeredSectionUri ?? webMap.Section.GetMappingUrl();

            if (registeredSectionUri == null)
            {
                RegisterEmptyHandler(sectionUri);
            }

            string token  = webMap.GetMappingToken();
            string mapUri = webMap.GetMappingUrl();

            // map URI for empty Catch URI on the blending token
            if (webMap.Url != null && !Blender.IsMapped(sectionUri, token))
            {
                Blender.MapUri(sectionUri, token);
            }

            // map URI for WebMap's Catch URI on the same blending token;
            // this will be calling by WebsiteProvider
            if (!Blender.IsMapped(mapUri, token))
            {
                RegisterEmptyHandler(mapUri);
                Blender.MapUri(mapUri, token);
            }

            // map URI for WebMap's Pin URI on the same token
            Blender.MapUri(webMap.ForeignUrl, token);
        }
Esempio n. 2
0
        protected void RegisterMap()
        {
            Blender.MapUri("/chatter/app-name", "app-name");
            Blender.MapUri("/chatter/menu", "menu");

            Blender.MapUri <Person>("/chatter/partials/people/{?}");

            #region Custom application ontology mapping
            Blender.MapUri <ChatMessage>("/chatter/partials/chatmessages/{?}",
                                         paramsFrom => paramsFrom,
                                         paramsTo =>
            {
                var objectId = paramsTo[0];
                var message  = DbHelper.FromID(DbHelper.Base64DecodeObjectID(objectId)) as ChatMessage;
                return(message.IsDraft ? null : paramsTo);
            });
            Blender.MapUri <ChatMessage>("/chatter/partials/chatmessages-draft/{?}",
                                         paramsFrom => paramsFrom,
                                         paramsTo =>
            {
                var objectId = paramsTo[0];
                var message  = DbHelper.FromID(DbHelper.Base64DecodeObjectID(objectId)) as ChatMessage;
                return(message.IsDraft ? paramsTo : null);
            });

            Blender.MapUri <ChatAttachment>("/chatter/partials/chatattachments/{?}");
            Blender.MapUri <ChatDraftAnnouncement>("/chatter/partials/chatdraftannouncements/{?}");
            Blender.MapUri <ChatWarning>("/chatter/partials/chatwarnings/{?}");
            #endregion
        }
Esempio n. 3
0
        public void Register()
        {
            Application.Current.Use(new HtmlFromJsonProvider());
            Application.Current.Use(new PartialToStandaloneHtmlProvider());

            Handle.GET("/launchpad", () =>
            {
                var master = this.GetMasterPageFromSession();

                if (!(master.CurrentPage is LaunchpadPage))
                {
                    master.CurrentPage = Self.GET("/launchpad/partial/launchpad");
                }
                return(master);
            });

            Handle.GET("/launchpad/partial/launchpad", () =>
            {
                string layout = Layout.GetSetup("/Launchpad")?.Value;
                if (layout == null)
                {
                    // workaround for https://github.com/Starcounter/Starcounter/issues/3072
                    // set default value
                    // consider moving to HTML, or pre-populatind default layouts
                    layout = "{\"width\": \"1000\", \"items\":[]}";
                }

                return(new LaunchpadPage
                {
                    Applications = Self.GET <Json>("/launchpad/applications"),
                    Layout = layout
                });
            }, new HandlerOptions {
                SelfOnly = true
            });

            Handle.GET("/launchpad/applications", () => new Json());

            Handle.GET("/launchpad/settings", () =>
            {
                var master = this.GetMasterPageFromSession();

                master.CurrentPage = Self.GET("/launchpad/partial/settings");

                return(master);
            });

            Handle.GET("/launchpad/partial/settings", () => new SettingsPage());

            Blender.MapUri("/launchpad/partial/launchpad", string.Empty, new string[] { "launchpad" }); // launchpad panel; used in Launcher/Website
            Blender.MapUri("/launchpad/partial/settings", string.Empty, new string[] { "settings" });
        }
Esempio n. 4
0
 public void Register()
 {
     Blender.MapUri("/signin/app-name", string.Empty, new string[] { "app", "icon" });
     Blender.MapUri("/signin/user", string.Empty, new string[] { "user" });                  //expandable icon
     //can't find "userform" token anywhere inside StarcounterApps
     Blender.MapUri("/signin/signinuser", string.Empty, new string[] { "userform" });        //inline form
     Blender.MapUri("/signin/signinuser?{?}", string.Empty, new string[] { "redirection" }); //inline form
     Blender.MapUri("/signin/settings", string.Empty, new string[] { "settings" });
     Blender.MapUri("/signin/user/authentication/password/{?}", string.Empty, new string[] { "authentication-password" });
     Blender.MapUri("/signin/user/authentication/settings/{?}", string.Empty, new string[] { "authentication-settings" });
     //can't find "userimage-default" token anywhere inside StarcounterApps
     Blender.MapUri("/signin/partial/user/image", string.Empty, new string[] { "userimage-default" });  // default user image
 }
Esempio n. 5
0
        static void Main()
        {
            Application.Current.Use(new HtmlFromJsonProvider());
            Application.Current.Use(new PartialToStandaloneHtmlProvider());

            PopulateList();

            Handle.GET("/PetOwnerList", () =>
            {
                var listPage = GetListPage();

                listPage.Owners.Data = Db.SQL("SELECT o FROM SharedModel.PetOwner o");

                return(listPage);
            });

            Handle.GET("/PetOwnerList/partials/PetEntry/{?}", (string ownerId) => new Json());
            Blender.MapUri("/PetOwnerList/partials/PetEntry/{?}", "PetInfo");
        }
Esempio n. 6
0
        static void Main()
        {
            Handle.GET("/PetImageProvider/partials/petimage/{?}", (string ownerId) =>
            {
                var imageFromType = new Dictionary <PetType, string>()
                {
                    { PetType.Cat, "http://www.cats.org.uk/uploads/images/pages/photo_latest14.jpg" },
                    { PetType.Dog, "http://cdn1-www.dogtime.com/assets/uploads/2011/01/file_23262_entlebucher-mountain-dog-460x290.jpg" },
                    { PetType.Fish, "https://vignette2.wikia.nocookie.net/pixar/images/8/82/Nemo.png/revision/latest?cb=20110504131029" }
                };

                var petOwner    = DbHelper.FromID(DbHelper.Base64DecodeObjectID(ownerId)) as PetOwner;
                PetType petType = petOwner.Pet.Type;

                return(new PetImage {
                    Src = imageFromType[petType]
                });
            });

            Blender.MapUri("/PetImageProvider/partials/petimage/{?}", "PetInfo");
        }
Esempio n. 7
0
        public static void Register()
        {
            Blender.MapUri("/useradmin/menu", string.Empty, new string[] { "menu" });
            Blender.MapUri("/useradmin/app-name", string.Empty, new string[] { "app", "icon" });
            Blender.MapUri("/useradmin/search/{?}", string.Empty, new string[] { "search" });
            Blender.MapUri("/useradmin/partial/unauthenticated?return_uri={?}", string.Empty, new string[] { "redirection" });
            Blender.MapUri("/useradmin/user/authentication/password/{?}", string.Empty, new string[] { "authentication-password" });
            Blender.MapUri("/useradmin/user/authentication/settings/{?}", string.Empty, new string[] { "authentication-settings" });
            // Mapping issue
            // https://github.com/Starcounter/Starcounter/issues/2902
            Blender.MapUri <Person>("/UserAdmin/persons/{?}",
                                    paramsFrom =>
            {
                var objectId = paramsFrom[0];
                var user     = Db.SQL <SystemUser>("SELECT o FROM Simplified.Ring3.SystemUser o WHERE o.ObjectID=?", objectId).First;
                if (user != null)
                {
                    paramsFrom[0] = user.WhatIs.Key;
                }

                return(null);
            },
                                    paramsTo =>
            {
                var objectId = paramsTo[0];
                var user     = Db.SQL <SystemUser>("SELECT o FROM Simplified.Ring3.SystemUser o WHERE o.WhatIs.ObjectID=?", objectId).First;

                if (user != null)
                {
                    paramsTo[0] = user.Key;
                    return(paramsTo);
                }
                return(null);
            }
                                    , new string[] { "page" });
        }
Esempio n. 8
0
        static void Main()
        {
            var app = Application.Current;

            app.Use(new HtmlFromJsonProvider());
            app.Use(new PartialToStandaloneHtmlProvider());

            DummyData.Create();

            Handle.GET("/KitchenSink/json", () => { return(new Json()); });

            Handle.GET("/KitchenSink/partial/mainpage", () => new MainPage());
            Handle.GET("/KitchenSink/mainpage", () => WrapPage <MainPage>("/KitchenSink/partial/mainpage"));

            Handle.GET("/KitchenSink", () => { return(Self.GET("/KitchenSink/mainpage")); });

            Handle.GET("/KitchenSink/partial/button", () => new ButtonPage());
            Handle.GET("/KitchenSink/button", () => WrapPage <ButtonPage>("/KitchenSink/partial/button"));

            Handle.GET("/KitchenSink/partial/breadcrumb",
                       () => { return(Db.Scope(() => { return new BreadcrumbPage(); })); });
            Handle.GET("/KitchenSink/breadcrumb", () => WrapPage <BreadcrumbPage>("/KitchenSink/partial/breadcrumb"));

            Handle.GET("/KitchenSink/partial/chart", () => new ChartPage());
            Handle.GET("/KitchenSink/chart", () => WrapPage <ChartPage>("/KitchenSink/partial/chart"));

            Handle.GET("/KitchenSink/partial/checkbox", () => new CheckboxPage());
            Handle.GET("/KitchenSink/checkbox", () => WrapPage <CheckboxPage>("/KitchenSink/partial/checkbox"));

            Handle.GET("/KitchenSink/partial/togglebutton", () => new ToggleButtonPage());
            Handle.GET("/KitchenSink/togglebutton",
                       () => WrapPage <ToggleButtonPage>("/KitchenSink/partial/togglebutton"));

            Handle.GET("/KitchenSink/partial/datagrid", () => new DatagridPage());
            Handle.GET("/KitchenSink/datagrid", () => WrapPage <DatagridPage>("/KitchenSink/partial/datagrid"));

            Handle.GET("/KitchenSink/partial/decimal", () => new DecimalPage());
            Handle.GET("/KitchenSink/decimal", () => WrapPage <DecimalPage>("/KitchenSink/partial/decimal"));

            Handle.GET("/KitchenSink/partial/dropdown", () => new DropdownPage());
            Handle.GET("/KitchenSink/dropdown", () => WrapPage <DropdownPage>("/KitchenSink/partial/dropdown"));

            Handle.GET("/KitchenSink/partial/html", () => new HtmlPage());
            Handle.GET("/KitchenSink/html", () => WrapPage <HtmlPage>("/KitchenSink/partial/html"));

            Handle.GET("/KitchenSink/partial/integer", () => new IntegerPage());
            Handle.GET("/KitchenSink/integer", () => WrapPage <IntegerPage>("/KitchenSink/partial/integer"));

            Handle.GET("/KitchenSink/partial/Geo", () =>
            {
                return(Db.Scope(() =>
                {
                    var geoPage = new GeoPage();
                    geoPage.Init();
                    return geoPage;
                }));
            });
            Handle.GET("/KitchenSink/Geo", () => WrapPage <GeoPage>("/KitchenSink/partial/Geo"));

            Handle.GET("/KitchenSink/partial/markdown", () => new MarkdownPage());
            Handle.GET("/KitchenSink/markdown", () => WrapPage <MarkdownPage>("/KitchenSink/partial/markdown"));

            Handle.GET("/KitchenSink/partial/nested", () => new NestedPartial
            {
                Data = new AnyData()
            });
            Handle.GET("/KitchenSink/nested", () => WrapPage <NestedPartial>("/KitchenSink/partial/nested"));

            Handle.GET("/KitchenSink/partial/radiolist", () => new RadiolistPage());
            Handle.GET("/KitchenSink/radiolist", () => WrapPage <RadiolistPage>("/KitchenSink/partial/radiolist"));

            Handle.GET("/KitchenSink/partial/multiselect", () => new MultiselectPage());
            Handle.GET("/KitchenSink/multiselect", () => WrapPage <MultiselectPage>("/KitchenSink/partial/multiselect"));

            Handle.GET("/KitchenSink/partial/password", () => new PasswordPage());
            Handle.GET("/KitchenSink/password", () => WrapPage <PasswordPage>("/KitchenSink/partial/password"));

            Handle.GET("/KitchenSink/partial/table", () => new TablePage());
            Handle.GET("/KitchenSink/table", () => WrapPage <TablePage>("/KitchenSink/partial/table"));

            Handle.GET("/KitchenSink/partial/text", () => new TextPage());
            Handle.GET("/KitchenSink/text", () => WrapPage <TextPage>("/KitchenSink/partial/text"));

            Handle.GET("/KitchenSink/partial/textarea", () => new TextareaPage());
            Handle.GET("/KitchenSink/textarea", () => WrapPage <TextareaPage>("/KitchenSink/partial/textarea"));

            Handle.GET("/KitchenSink/partial/radio", () => new RadioPage());
            Handle.GET("/KitchenSink/radio", () => WrapPage <RadioPage>("/KitchenSink/partial/radio"));

            Handle.GET("/KitchenSink/partial/Redirect", () => new RedirectPage());
            Handle.GET("/KitchenSink/Redirect", () => WrapPage <RedirectPage>("/KitchenSink/partial/Redirect"));

            Handle.GET("/KitchenSink/partial/Validation", () => new ValidationPage());
            Handle.GET("/KitchenSink/Validation", () => WrapPage <ValidationPage>("/KitchenSink/partial/Validation"));

            Handle.GET("/KitchenSink/Redirect/{?}", (string param) =>
            {
                var master            = WrapPage <RedirectPage>("/KitchenSink/partial/Redirect") as MasterPage;
                var page              = master.CurrentPage as RedirectPage;
                page.YourFavoriteFood = "You've got some tasty " + param;
                return(master);
            });

            Handle.GET("/KitchenSink/partial/url", () => new UrlPage());
            Handle.GET("/KitchenSink/url", () => WrapPage <UrlPage>("/KitchenSink/partial/url"));

            Handle.GET("/KitchenSink/partial/datepicker", () => new DatepickerPage());
            Handle.GET("/KitchenSink/datepicker", () => WrapPage <DatepickerPage>("/KitchenSink/partial/datepicker"));

            Handle.GET("/KitchenSink/partial/fileupload", () => new FileUploadPage());
            Handle.GET("/KitchenSink/fileupload", () => WrapPage <FileUploadPage>("/KitchenSink/partial/fileupload"));

            Handle.GET("/KitchenSink/partial/callback", () => new CallbackPage());
            Handle.GET("/KitchenSink/callback", () => WrapPage <CallbackPage>("/KitchenSink/partial/callback"));

            Handle.GET("/KitchenSink/partial/dialog", () => new DialogPage());
            Handle.GET("/KitchenSink/dialog", () => WrapPage <DialogPage>("/KitchenSink/partial/dialog"));

            Handle.GET("/KitchenSink/partial/progressbar", () => new ProgressBarPage());
            Handle.GET("/Kitchensink/progressbar", () => WrapPage <ProgressBarPage>("/KitchenSink/partial/progressbar"));

            Handle.GET("/KitchenSink/partial/lazyloading", () => new LazyLoadingPage());
            Handle.GET("/Kitchensink/lazyloading", () => WrapPage <LazyLoadingPage>("/KitchenSink/partial/lazyloading"));

            Handle.GET("/KitchenSink/partial/pagination", () => new PaginationPage());
            Handle.GET("/Kitchensink/pagination", () => WrapPage <PaginationPage>("/KitchenSink/partial/pagination"));

            Handle.GET("/KitchenSink/partial/flashmessage", () => new FlashMessagePage());
            Handle.GET("/Kitchensink/flashmessage", () => WrapPage <FlashMessagePage>("/KitchenSink/partial/flashmessage"));

            Handle.GET("/KitchenSink/partial/clientlocalstate", () => new ClientLocalStatePage());
            Handle.GET("/KitchenSink/clientlocalstate", () => WrapPage <ClientLocalStatePage>("/KitchenSink/partial/clientlocalstate"));

            Handle.GET("/KitchenSink/partial/cookie", (Request request) =>
            {
                string name     = "KitchenSink";
                CookiePage page = new CookiePage();
                Cookie cookie   = request.Cookies.Select(x => new Cookie(x)).FirstOrDefault(x => x.Name == name);

                if (cookie != null)
                {
                    page.RequestCookie = cookie.Value;
                }

                cookie = new Cookie()
                {
                    Name    = name,
                    Value   = string.Format("KitchenSinkCookie-{0}", DateTime.Now.ToString()),
                    Expires = DateTime.Now.AddDays(1)
                };

                Handle.AddOutgoingCookie(name, cookie.GetFullValueString());

                return(page);
            });
            Handle.GET("/KitchenSink/cookie", () => WrapPage <CookiePage>("/KitchenSink/partial/cookie"));

            HandleFile.GET("/KitchenSink/fileupload/upload", task =>
            {
                Session.ScheduleTask(task.SessionId, (session, id) =>
                {
                    var master = session.Store[nameof(MasterPage)] as MasterPage;

                    if (master == null)
                    {
                        return;
                    }

                    var page = master.CurrentPage as FileUploadPage;

                    if (page == null)
                    {
                        return;
                    }

                    var item = page.Tasks.FirstOrDefault(x => x.FileName == task.FileName);

                    if (task.State == HandleFile.UploadTaskState.Error)
                    {
                        if (item != null)
                        {
                            page.Tasks.Remove(item);
                        }
                    }
                    else if (task.State == HandleFile.UploadTaskState.Completed)
                    {
                        if (item != null)
                        {
                            page.Tasks.Remove(item);
                        }

                        var file = page.Files.FirstOrDefault(x => x.FileName == task.FileName);

                        if (file == null)
                        {
                            file = page.Files.Add();
                        }

                        file.FileName = task.FileName;
                        file.FileSize = task.FileSize;
                        file.FilePath = task.FilePath;
                    }
                    else
                    {
                        if (item == null)
                        {
                            item = page.Tasks.Add();
                        }

                        item.FileName = task.FileName;
                        item.FileSize = task.FileSize;
                        item.Progress = task.Progress;
                    }

                    session.CalculatePatchAndPushOnWebSocket();
                });
            });

            Handle.GET("/KitchenSink/partial/autocomplete", () => Db.Scope(() => new AutocompletePage()));
            Handle.GET("/KitchenSink/autocomplete", () => WrapPage <AutocompletePage>("/KitchenSink/partial/autocomplete"));

            Handle.GET("/KitchenSink/nav", () => { return(new NavPage()); }, new HandlerOptions()
            {
                SelfOnly = true
            });

            Handle.GET("/KitchenSink/app-name", () => { return(new AppName()); });

            Handle.GET("/KitchenSink/menu", () => { return(new AppMenuPage()); });

            Blender.MapUri("/KitchenSink/menu", string.Empty, new string[] { "menu" });
            Blender.MapUri("/KitchenSink/app-name", string.Empty, new string[] { "app", "icon" });
        }
Esempio n. 9
0
 public void Register()
 {
     Blender.MapUri("/launchpad/applications", string.Empty, new string[] { "app", "icon" });
 }
Esempio n. 10
0
 public void Register()
 {
     Blender.MapUri("/website/app-name", "app-name");
 }
Esempio n. 11
0
        public void Register()
        {
            Application.Current.Use(new HtmlFromJsonProvider());
            Application.Current.Use(new PartialToStandaloneHtmlProvider());

            Handle.GET("/Timeline", () =>
            {
                return(Self.GET("/timeline/eventList"));
            });

            Handle.GET("/timeline/eventList", () =>
            {
                return(Db.Scope <MasterPage>(() => {
                    var master = this.GetMasterPageFromSession();

                    master.ActionRowPage = Self.GET("/timeline/partials/action-row");
                    master.CurrentPage = Self.GET("/timeline/partials/event-list");

                    return master;
                }));
            }, new HandlerOptions {
                SelfOnly = true
            });

            Handle.GET("/timeline/partials/event-list", () =>
            {
                EventListPage page = new EventListPage()
                {
                    Data = null
                };
                return(page);
            }, new HandlerOptions {
                SelfOnly = true
            });

            Handle.GET("/timeline/partials/action-row", () =>
            {
                ActionsPage page = new ActionsPage();
                page.LoadContributions();
                return(page);
            }, new HandlerOptions {
                SelfOnly = true
            });

            Handle.GET("/timeline/eventList/{?}", (string personId) =>
            {
                return(Db.Scope <MasterPage>(() => {
                    var master = this.GetMasterPageFromSession();

                    master.ActionRowPage = Self.GET("/timeline/partials/action-row/" + personId);
                    master.CurrentPage = Self.GET("/timeline/partials/event-list/" + personId);

                    return master;
                }));
            }, new HandlerOptions {
                SelfOnly = true
            });

            Handle.GET("/timeline/partials/event-list/{?}", (string personId) =>
            {
                EventListPage page = new EventListPage()
                {
                    PersonId = personId, Data = null
                };
                return(page);
            }, new HandlerOptions {
                SelfOnly = true
            });

            Handle.GET("/timeline/partials/action-row/{?}", (string personId) =>
            {
                ActionsPage page = new ActionsPage()
                {
                    PersonId = personId, Data = null
                };
                page.LoadContributions();
                return(page);
            }, new HandlerOptions {
                SelfOnly = true
            });


            Handle.GET("/timeline/contributions", () =>
            {
                return(new Json());
            }, new HandlerOptions {
                SelfOnly = true
            });
            Blender.MapUri("/timeline/contributions", "contributions");

            Handle.GET("/timeline/timeline-item/{?}", (string eventId) =>
            {
                return(new Json());
            }, new HandlerOptions {
                SelfOnly = true
            });
            Blender.MapUri("/timeline/timeline-item/{?}", "timeline-item");

            // Provides the People app with a timeline (+ an actions row, where events can be created)
            Handle.GET("/timeline/partial/timeline/{?}", (string personId) => {
                return(Self.GET("/timeline/eventList/" + personId));
            }, new HandlerOptions {
                SelfOnly = true
            });

            //Add Blender.MapUri<Simplified.Ring2.Person>("/people/partials/persons/{?}"); to the People app > will cause this to open in people app
            Blender.MapUri <Simplified.Ring2.Person>("/timeline/partial/timeline/{?}");


            // Instead of having the "delete this event" code in every app, the call to this handler triggers the deletion event.
            // That way timeline app will have full control of the deletion of events, no matter if the "cancel" button (from inside an event) is clicked,
            // or if the "X" (delete) button from the timeline app is clicked
            Handle.GET("/timeline/partial/delete-event/{?}", (string eventKey) =>
            {
                Event thisEvent = DbHelper.FromID(DbHelper.Base64DecodeObjectID(eventKey)) as Event;
                HelperFunctions.DeleteEvent(thisEvent);
                return(new Json());
            }, new HandlerOptions {
                SelfOnly = true
            });
            Blender.MapUri("/timeline/partial/delete-event/{?}", "delete-event");
        }
Esempio n. 12
0
        public void Register()
        {
            Application.Current.Use(new HtmlFromJsonProvider());
            Application.Current.Use(new PartialToStandaloneHtmlProvider());

            //Testing JWT

            /*Handle.GET("/signin/jwt/{?}/{?}", (string Username, string Password) => {
             *  string message;
             *  SystemUserSession session = SignInOut.SignInSystemUser(Username, Password, null, out message);
             *
             *  if (session != null) {
             *      string jwt = JWT.JsonWebToken.Encode(new { Username = Username, Issuer = "Polyjuice.SignIn" }, session.Token.User.Password, JWT.JwtHashAlgorithm.HS256);
             *      Handle.AddOutgoingHeader("x-jwt", jwt);
             *  }
             *
             *  return 200;
             * });*/

            Application.Current.Use((Request req) =>
            {
                Cookie cookie = GetSignInCookie();

                if (cookie != null)
                {
                    if (Session.Current == null)
                    {
                        Session.Current = new Session(SessionOptions.PatchVersioning);
                    }

                    SystemUserSession session = SystemUser.SignInSystemUser(cookie.Value);

                    if (session != null)
                    {
                        RefreshAuthCookie(session);
                    }
                }

                return(null);
            });

            Handle.GET("/signin/user", () =>
            {
                MasterPage master = this.GetMaster();

                if (master.SignInPage != null)
                {
                    return(master.SignInPage);
                }

                Cookie cookie   = GetSignInCookie();
                SignInPage page = new SignInPage()
                {
                    Data = null
                };

                master.SignInPage = page;

                if (cookie != null)
                {
                    SystemUser.SignInSystemUser(cookie.Value);
                    master.RefreshSignInState();
                }

                //Testing JWT

                /*if (Handle.IncomingRequest.HeadersDictionary.ContainsKey("x-jwt")) {
                 *  System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                 *  string jwt = Handle.IncomingRequest.HeadersDictionary["x-jwt"];
                 *  Dictionary<string, string> payload = JWT.JsonWebToken.DecodeToObject<Dictionary<string, string>>(jwt, string.Empty, false);
                 *  string username = payload["Username"];
                 *  SystemUser user = Db.SQL<SystemUser>("SELECT su FROM Simplified.Ring3.SystemUser su WHERE su.Username = ?", username).First;
                 *
                 *  try {
                 *      JWT.JsonWebToken.DecodeToObject<Dictionary<string, string>>(jwt, user.Password, true);
                 *      page.SetAuthorizedState(SignInOut.SignInSystemUser(user));
                 *  } catch (JWT.SignatureVerificationException) {
                 *  }
                 * }*/

                return(page);
            });

            Handle.GET("/signin/partial/signout", HandleSignOut, new HandlerOptions()
            {
                SkipRequestFilters = true
            });

            Handle.GET("/signin/signinuser", HandleSignInForm);
            Handle.GET <string>("/signin/signinuser?{?}", HandleSignInForm);

            Handle.GET("/signin/profile", () =>
            {
                MasterPage master = this.GetMaster();

                master.RequireSignIn = true;
                master.Open("/signin/partial/profile-form");

                return(master);
            });

            Handle.GET("/signin/partial/signin-form", () => new SignInFormPage()
            {
                Data = null
            }, new HandlerOptions()
            {
                SelfOnly = true
            });
            Handle.GET("/signin/partial/alreadyin-form", () => new AlreadyInPage()
            {
                Data = null
            },
                       new HandlerOptions()
            {
                SelfOnly = true
            });
            Handle.GET("/signin/partial/restore-form", () => new RestorePasswordFormPage(),
                       new HandlerOptions()
            {
                SelfOnly = true
            });
            Handle.GET("/signin/partial/profile-form", () => new ProfileFormPage()
            {
                Data = null
            },
                       new HandlerOptions()
            {
                SelfOnly = true
            });
            Handle.GET("/signin/partial/accessdenied-form", () => new AccessDeniedPage(),
                       new HandlerOptions()
            {
                SelfOnly = true
            });

            Handle.GET("/signin/partial/main-form", () => new MainFormPage()
            {
                Data = null
            },
                       new HandlerOptions()
            {
                SelfOnly = true
            });

            Handle.GET("/signin/partial/user/image", () => new UserImagePage());
            Handle.GET("/signin/partial/user/image/{?}", (string objectId) => new Json(),
                       new HandlerOptions {
                SelfOnly = true
            });

            Handle.GET("/signin/generateadminuser", (Request request) =>
            {
                if (Db.SQL("SELECT o FROM Simplified.Ring3.SystemUser o").First != null)
                {
                    Handle.SetOutgoingStatusCode(403);
                    return("Unable to generate admin user: database is not empty!");
                }

                string ip = request.ClientIpAddress.ToString();

                if (ip == "127.0.0.1" || ip == "localhost")
                {
                    SignInOut.AssureAdminSystemUser();

                    return("Default admin user has been successfully generated.");
                }

                Handle.SetOutgoingStatusCode(403);
                return("Access denied.");
            }, new HandlerOptions()
            {
                SkipRequestFilters = true
            });

            Handle.POST("/signin/partial/signin", (Request request) =>
            {
                NameValueCollection values = HttpUtility.ParseQueryString(request.Body);
                string username            = values["username"];
                string password            = values["password"];
                string rememberMe          = values["rememberMe"];

                HandleSignIn(username, password, rememberMe);
                Session.Current.CalculatePatchAndPushOnWebSocket();

                return(200);
            }, new HandlerOptions()
            {
                SkipRequestFilters = true
            });

            Handle.GET("/signin/admin/settings", (Request request) =>
            {
                Json page;
                if (!AuthorizationHelper.TryNavigateTo("/signin/admin/settings", request, out page))
                {
                    return(page);
                }

                return(Db.Scope(() =>
                {
                    var settingsPage = new SettingsPage
                    {
                        Html = "/SignIn/viewmodels/SettingsPage.html",
                        Uri = request.Uri,
                        Data = MailSettingsHelper.GetSettings()
                    };
                    return settingsPage;
                }));
            });

            // Reset password
            Handle.GET("/signin/user/resetpassword?{?}", (string query, Request request) =>
            {
                NameValueCollection queryCollection = HttpUtility.ParseQueryString(query);
                string token = queryCollection.Get("token");

                MasterPage master = this.GetMaster();

                if (token == null)
                {
                    // TODO:
                    master.Partial = null; // (ushort)System.Net.HttpStatusCode.NotFound;
                    return(master);
                }

                // Retrive the resetPassword instance
                ResetPassword resetPassword = Db.SQL <ResetPassword>("SELECT o FROM Simplified.Ring6.ResetPassword o WHERE o.Token=? AND o.Expire>?", token, DateTime.UtcNow).First;

                if (resetPassword == null)
                {
                    // TODO: Show message "Reset token already used or expired"
                    master.Partial = null; // (ushort)System.Net.HttpStatusCode.NotFound;
                    return(master);
                }

                if (resetPassword.User == null)
                {
                    // TODO: Show message "User deleted"
                    master.Partial = null; // (ushort)System.Net.HttpStatusCode.NotFound;
                    return(master);
                }

                SystemUser systemUser = resetPassword.User;

                ResetPasswordPage page = new ResetPasswordPage()
                {
                    Html = "/SignIn/viewmodels/ResetPasswordPage.html",
                    Uri  = "/signin/user/resetpassword"
                           //Uri = request.Uri // TODO:
                };

                page.ResetPassword = resetPassword;

                if (systemUser.WhoIs != null)
                {
                    page.FullName = systemUser.WhoIs.FullName;
                }
                else
                {
                    page.FullName = systemUser.Username;
                }

                master.Partial = page;

                return(master);
            });

            Handle.GET("/signin/user/authentication/settings/{?}", (string userid, Request request) =>
            {
                Json page;
                if (!AuthorizationHelper.TryNavigateTo("/signin/user/authentication/settings/{?}", request, out page))
                {
                    return(new Json());
                }

                // Get system user
                SystemUser user = Db.SQL <SystemUser>("SELECT o FROM Simplified.Ring3.SystemUser o WHERE o.ObjectID = ?", userid).FirstOrDefault();

                if (user == null)
                {
                    // TODO: Return a "User not found" page
                    return(new Json());
                    //return (ushort)System.Net.HttpStatusCode.NotFound;
                }

                SystemUser systemUser      = SystemUser.GetCurrentSystemUser();
                SystemUserGroup adminGroup = Db.SQL <SystemUserGroup>("SELECT o FROM Simplified.Ring3.SystemUserGroup o WHERE o.Name = ?",
                                                                      AuthorizationHelper.AdminGroupName).FirstOrDefault();

                // Check if current user has permission to get this user instance
                if (AuthorizationHelper.IsMemberOfGroup(systemUser, adminGroup))
                {
                    if (user.WhoIs is Person)
                    {
                        page = Db.Scope(() => new SystemUserAuthenticationSettings
                        {
                            Html         = "/SignIn/viewmodels/SystemUserAuthenticationSettings.html",
                            Uri          = request.Uri,
                            Data         = user,
                            UserPassword = Self.GET("/signin/user/authentication/password/" + user.GetObjectID())
                        });

                        return(page);
                    }
                }

                return(new Json());
            }, new HandlerOptions {
                SelfOnly = true
            });

            Handle.GET("/signin/user/authentication/password/{?}", (string userid, Request request) =>
            {
                // Get system user
                SystemUser user = Db.SQL <SystemUser>("SELECT o FROM Simplified.Ring3.SystemUser o WHERE o.ObjectID = ?", userid).FirstOrDefault();

                if (user == null)
                {
                    return(new Json());
                }

                Json page = Db.Scope(() => new SetPasswordPage
                {
                    Html = "/SignIn/viewmodels/SetPasswordPage.html",
                    Data = user
                });

                return(page);
            }, new HandlerOptions {
                SelfOnly = true
            });

            Blender.MapUri("/signin/user", "user");                      //expandable icon; used in Launcher
            Blender.MapUri("/signin/signinuser", "userform");            //inline form; used in RSE Launcher
            Blender.MapUri("/signin/signinuser?{?}", "userform-return"); //inline form; used in UserAdmin
            Blender.MapUri("/signin/admin/settings", "settings");
            Blender.MapUri("/signin/user/authentication/password/{?}", "authentication-password");
            Blender.MapUri("/signin/user/authentication/settings/{?}", "authentication-settings");
            Blender.MapUri("/signin/partial/user/image", "userimage-default");  // default user image
        }