Beispiel #1
0
        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"));
            }
        }
		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"));
			}
		}