public override void Execute()
        {
            WriteLiteral("\r\n\r\n");


            WriteLiteral("\r\n");



            Page.Title = AdminResources.SecurityTitle;

            if (AdminSecurity.HasAdminPassword())
            {
                SiteAdmin.RedirectToHome(Response);
                return;
            }

            string url = SiteAdmin.GetRedirectUrl(SiteAdmin.AdminVirtualPath);


            WriteLiteral("\r\n");


            Write(Html.Raw(AdminResources.EnableInstructions));

            WriteLiteral("\r\n<br />\r\n<p>\r\n    ");


            Write(Html.Raw(String.Format(CultureInfo.CurrentCulture, AdminResources.ContinueAfterEnableText, Html.Encode(Href(url)))));

            WriteLiteral("\r\n</p>\r\n\r\n");
        }
Пример #2
0
        public override void Execute()
        {
            WriteLiteral("\r\n\r\n");



            #line 4 "..\..\Register.cshtml"

            Page.Title = AdminResources.RegisterTitle;
            var adminPath = SiteAdmin.AdminVirtualPath.TrimStart('~');
            Page.Desc = String.Format(CultureInfo.CurrentCulture, AdminResources.RegisterDesc, Html.Encode(adminPath));

            // If the password is already set the redirect to login
            if (AdminSecurity.HasAdminPassword())
            {
                SiteAdmin.RedirectToLogin(Response);
                return;
            }

            if (IsPost)
            {
                AntiForgery.Validate();

                var password          = Request.Form["password"];
                var reenteredPassword = Request.Form["repassword"];
                if (password.IsEmpty())
                {
                    ModelState.AddError("password", AdminResources.Validation_PasswordRequired);
                }
                else if (password != reenteredPassword)
                {
                    ModelState.AddError("repassword", AdminResources.Validation_PasswordsDoNotMatch);
                }

                if (ModelState.IsValid)
                {
                    // Save the admin password
                    if (AdminSecurity.SaveTemporaryPassword(password))
                    {
                        // Get the return url
                        var returnUrl = SiteAdmin.GetReturnUrl(Request) ?? SiteAdmin.AdminVirtualPath;

                        // Redirect to the return url
                        Response.Redirect(returnUrl);
                    }
                    else
                    {
                        // Add a validation error since creating the password.txt failed
                        ModelState.AddFormError(AdminResources.AdminModuleRequiresAccessToAppData);
                    }
                }
            }



            #line default
            #line hidden
            WriteLiteral("\r\n<br/>\r\n\r\n");



            #line 47 "..\..\Register.cshtml"
            Write(Html.ValidationSummary());


            #line default
            #line hidden
            WriteLiteral("\r\n\r\n<form method=\"post\" action=\"\">\r\n");



            #line 50 "..\..\Register.cshtml"
            Write(AntiForgery.GetHtml());


            #line default
            #line hidden
            WriteLiteral("\r\n<fieldset>\r\n    <ol>\r\n        <li class=\"password\">\r\n            <label for=\"pa" +
                         "ssword\">");



            #line 54 "..\..\Register.cshtml"
            Write(AdminResources.EnterPassword);


            #line default
            #line hidden
            WriteLiteral("</label>\r\n            ");



            #line 55 "..\..\Register.cshtml"
            Write(Html.Password("password"));


            #line default
            #line hidden
            WriteLiteral(" ");



            #line 55 "..\..\Register.cshtml"
            Write(Html.ValidationMessage("password", "*"));


            #line default
            #line hidden
            WriteLiteral("\r\n        </li>\r\n        <li class=\"password\">\r\n            <label>");



            #line 58 "..\..\Register.cshtml"
            Write(AdminResources.ReenterPassword);


            #line default
            #line hidden
            WriteLiteral("</label>\r\n            ");



            #line 59 "..\..\Register.cshtml"
            Write(Html.Password("repassword"));


            #line default
            #line hidden
            WriteLiteral(" ");



            #line 59 "..\..\Register.cshtml"
            Write(Html.ValidationMessage("repassword", "*"));


            #line default
            #line hidden
            WriteLiteral("\r\n        </li>\r\n    </ol>\r\n    <p class=\"form-actions\">\r\n        <input type=\"su" +
                         "bmit\" value=\"");



            #line 63 "..\..\Register.cshtml"
            Write(AdminResources.CreatePassword);


            #line default
            #line hidden
            WriteLiteral("\" class=\"long-input\" />\r\n    </p>\r\n</fieldset>\r\n</form>\r\n");
        }
Пример #3
0
        public override void Execute()
        {
            WriteLiteral("\r\n\r\n");



            #line 4 "..\..\Login.cshtml"

            Page.Title = AdminResources.LoginTitle;

            // No admin password has been registered so redirect
            if (!AdminSecurity.HasAdminPassword())
            {
                SiteAdmin.RedirectToRegister(Response);
                return;
            }

            if (IsPost)
            {
                AntiForgery.Validate();
                var password = Request.Form["password"];

                if (AdminSecurity.CheckPassword(password))
                {
                    // Get the return url
                    var returnUrl = SiteAdmin.GetReturnUrl(Request) ?? SiteAdmin.AdminVirtualPath;

                    // Set the admin auth cookie
                    AdminSecurity.SetAuthCookie(Response);

                    // Redirect to the return url
                    Response.Redirect(returnUrl);
                }
                else
                {
                    ModelState.AddError("password", AdminResources.Validation_PasswordIncorrect);
                }
            }



            #line default
            #line hidden
            WriteLiteral("\r\n");


            DefineSection("Head", () => {
                WriteLiteral("\r\n    <script type=\"text/javascript\">\r\n    function showForgotPasswordInfo(){\r\n  " +
                             "      document.getElementById(\'forgotPasswordInfo\').style.display = \'\';\r\n    }\r\n" +
                             "    </script>\r\n");
            });

            WriteLiteral("\r\n\r\n");



            #line 41 "..\..\Login.cshtml"
            Write(Html.ValidationSummary());


            #line default
            #line hidden
            WriteLiteral("\r\n<br />\r\n\r\n<form method=\"post\" action=\"\">\r\n    ");



            #line 45 "..\..\Login.cshtml"
            Write(AntiForgery.GetHtml());


            #line default
            #line hidden
            WriteLiteral("\r\n    <fieldset>\r\n    <ol>\r\n        <li class=\"password\">\r\n            <label for" +
                         "=\"password\">");



            #line 49 "..\..\Login.cshtml"
            Write(AdminResources.Password);


            #line default
            #line hidden
            WriteLiteral(":</label>\r\n            ");



            #line 50 "..\..\Login.cshtml"
            Write(Html.Password("password"));


            #line default
            #line hidden
            WriteLiteral(" ");



            #line 50 "..\..\Login.cshtml"
            Write(Html.ValidationMessage("password", "*"));


            #line default
            #line hidden
            WriteLiteral("\r\n    </ol>\r\n    <p class=\"form-actions\">\r\n        <input type=\"submit\" value=\"");



            #line 53 "..\..\Login.cshtml"
            Write(AdminResources.Login);


            #line default
            #line hidden
            WriteLiteral("\" />\r\n    </p>\r\n    </fieldset>\r\n    <p>\r\n        <a href=\"#\" onclick=\"showForgot" +
                         "PasswordInfo(); return false;\">");



            #line 57 "..\..\Login.cshtml"
            Write(AdminResources.ForgotPassword);


            #line default
            #line hidden
            WriteLiteral("</a>\r\n    </p>\r\n</form>\r\n<br />\r\n");



            #line 61 "..\..\Login.cshtml"

            var passwordFileLocation = AdminSecurity.AdminPasswordFile.TrimStart('~', '/');
            var forgotPasswordHelp   = String.Format(CultureInfo.CurrentCulture, AdminResources.AdminPasswordChangeInstructions, Html.Encode(passwordFileLocation));



            #line default
            #line hidden
            WriteLiteral("<span id=\"forgotPasswordInfo\" style=\"display: none\">");



            #line 65 "..\..\Login.cshtml"
            Write(Html.Raw(forgotPasswordHelp));


            #line default
            #line hidden
            WriteLiteral("</span>");
        }