protected override void OnInit(EventArgs e) { base.OnInit(e); action = Request["action"]; version = typeof(N2.ContentItem).Assembly.GetName().Version; config = N2.Context.Current.Resolve <N2.Configuration.EditSection>().Installer; installationAllowed = AllowInstallationOption.Parse(config.AllowInstallation) != AllowInstallationOption.No; continueUrl = action == "install" ? config.InstallUrl : action == "upgrade" ? config.UpgradeUrl : action == "rebase" ? config.RebaseUrl : action == "fixClass" ? config.FixClassUrl.ToUrl().AppendQuery("id", Request["id"]).ToString() : config.InstallUrl; continueUrl = N2.Web.Url.ResolveTokens(continueUrl); System.Configuration.Configuration cfg; try { if (FormsAuthentication.Authenticate("admin", "changeme")) { needsPasswordChange = true; } else { if (TryOpenWebConfiguration(out cfg)) { var authentication = (AuthenticationSection)cfg.GetSection("system.web/authentication"); needsPasswordChange = authentication.Forms.Credentials.Users["admin"] == null && AllowInstallationOption.Parse(config.AllowInstallation) == AllowInstallationOption.AnonymousUser; } } } catch (Exception) { } autoLogin = Request["autologin"] == "true"; if (autoLogin) { return; } if (!TryOpenWebConfiguration(out cfg)) { FormsAuthentication.SetAuthCookie("admin", false); Response.Redirect(Url.Parse(Request.RawUrl).AppendQuery("autologin", "true")); } }
public static void CheckInstallationAllowed(HttpContext context) { if (AllowInstallationOption.Parse(N2.Context.Current.Resolve <N2.Configuration.EditSection>().Installer.AllowInstallation) != AllowInstallationOption.No) { return; } context.Response.Write("<html><head>"); context.Response.Write("<link rel='stylesheet' type='text/css' href='" + Url.ResolveTokens("{ManagementUrl}/Resources/bootstrap/css/bootstrap.min.css") + "' />"); context.Response.Write("<link rel='stylesheet' type='text/css' href='" + Url.ResolveTokens("{ManagementUrl}/Resources/Css/all.css") + "' />"); context.Response.Write("<link rel='stylesheet' type='text/css' href='" + Url.ResolveTokens("{ManagementUrl}/Resources/Css/framed.css") + "' />"); context.Response.Write("<link rel='stylesheet' type='text/css' href='" + Url.ResolveTokens("{ManagementUrl}/Resources/Css/themes/default.css") + "' />"); context.Response.Write("</head><body><div class='tabPanel' style='font-size:1.1em;width:800px;margin:10px auto;'>"); context.Response.Write(InstallationUnallowedHtml); context.Response.Write("</div></body></html>"); context.Response.End(); }