private static async Task RegisterPost(HttpContext context)
        {
            SetHTMLContentType(context);

            string result;
            bool   success;

            var model = new RegisterModel
            {
                username = context.Request.Form["username"].ToString(),
                email    = context.Request.Form["email"].ToString().NormalizeEmail(),
                error    = ""
            };

            try
            {
                (success, result) = await RegisterWithForm(context);
            }
            catch (Exception e)
            {
                model.error = "An unknown error happened while registering this account. Please try again later.";
                var templateContext = new TemplateContext(model);
                await context.Response.WriteAsync(await HTMLRenderer.Render(context, "Templates\\register.liquid", templateContext));

                return;
            }

            if (!success)
            {
                model.error = result;
                var templateContext = new TemplateContext(model);
                await context.Response.WriteAsync(await HTMLRenderer.Render(context, "Templates\\register.liquid", templateContext));
            }
            else
            {
                UserSessions.SetSessionCookie(context, result);
                await context.Response.WriteAsync(await HTMLRenderer.Render(context, "Templates\\registerSuccess.liquid", null));
            }
        }
        private static async Task LoginPost(HttpContext context)
        {
            SetHTMLContentType(context);

            string result;
            bool   success;

            var model = new LoginModel
            {
                email = context.Request.Form["email"].ToString().NormalizeEmail(),
            };

            try
            {
                (success, result) = await LoginWithForm(context);
            }
            catch (Exception e)
            {
                model.error = "An unknown error happened while logging in. Please try again later.";
                var templateContext = new TemplateContext(model);
                await context.Response.WriteAsync(await HTMLRenderer.Render(context, "Templates\\login.liquid", templateContext));

                return;
            }

            if (!success)
            {
                model.error = result;
                var templateContext = new TemplateContext(model);
                await context.Response.WriteAsync(await HTMLRenderer.Render(context, "Templates\\login.liquid", templateContext));
            }
            else
            {
                UserSessions.SetSessionCookie(context, result);
                context.Response.Redirect("/");
            }
        }