This commit is contained in:
Shannon
2014-02-27 10:16:30 +01:00
parent 429b5f7c01
commit 3b71a6c3a5
9 changed files with 102 additions and 81 deletions

View File

@@ -35,6 +35,16 @@ namespace Umbraco.Web.Install.Controllers
// It's not considered an upgrade if the ConfigurationStatus is missing or empty.
if (string.IsNullOrWhiteSpace(GlobalSettings.ConfigurationStatus) == false)
{
Version current;
if (Version.TryParse(GlobalSettings.ConfigurationStatus, out current))
{
//check if we are on the current version, and not let the installer execute
if (current == UmbracoVersion.Current)
{
return Redirect(SystemDirectories.Umbraco.EnsureEndsWith('/'));
}
}
var result = _umbracoContext.Security.ValidateCurrentUser(false);
switch (result)

View File

@@ -65,16 +65,6 @@ namespace Umbraco.Web.Install
return false;
}
}
///// <summary>
///// Override to throw exception instead of returning 401 result
///// </summary>
///// <param name="filterContext"></param>
//protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
//{
// //they aren't authorized but the app has installed
// throw new HttpException((int)global::System.Net.HttpStatusCode.Unauthorized, "You must login to view this resource.");
//}
}
}

View File

@@ -2,6 +2,8 @@
using System.Web;
using System.Web.Mvc;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Web.Security;
using umbraco.BasePages;
@@ -74,13 +76,12 @@ namespace Umbraco.Web.Install
}
/// <summary>
/// Override to throw exception instead of returning 401 result
/// Override to redirect instead of throwing an exception
/// </summary>
/// <param name="filterContext"></param>
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
//they aren't authorized but the app has installed
throw new HttpException((int)global::System.Net.HttpStatusCode.Unauthorized, "You must login to view this resource.");
filterContext.Result = new RedirectResult(SystemDirectories.Umbraco.EnsureEndsWith('/'));
}
}

View File

@@ -19,72 +19,64 @@ namespace Umbraco.Web.Install
{
//TODO: Add UserToken step to save our user token with Mother
var steps = new List<InstallSetupStep>();
if (status == InstallStatus.NewInstall)
var steps = new List<InstallSetupStep>(new InstallSetupStep[]
{
//The step order returned here is how they will appear on the front-end
steps.AddRange(new InstallSetupStep[]
new FilePermissionsStep()
{
new FilePermissionsStep()
{
ServerOrder = 0,
},
new UserStep(umbracoContext.Application)
{
ServerOrder = 4,
},
new DatabaseConfigureStep(umbracoContext.Application)
{
ServerOrder = 1,
},
new DatabaseInstallStep(umbracoContext.Application)
{
ServerOrder = 2,
},
new DatabaseUpgradeStep(umbracoContext.Application)
{
ServerOrder = 3,
},
new StarterKitDownloadStep()
{
ServerOrder = 5,
},
new StarterKitInstallStep(umbracoContext.Application, umbracoContext.HttpContext)
{
ServerOrder = 6,
},
new StarterKitCleanupStep()
{
ServerOrder = 7,
},
new SetUmbracoVersionStep(umbracoContext.Application, umbracoContext.HttpContext) {
ServerOrder = 8
}
});
return steps;
}
else
{
//TODO: Add steps for upgrades
}
return null;
}
public static bool IsNewInstall
{
get
{
var databaseSettings = ConfigurationManager.ConnectionStrings[GlobalSettings.UmbracoConnectionName];
if (databaseSettings != null && (
databaseSettings.ConnectionString.Trim() == string.Empty
&& databaseSettings.ProviderName.Trim() == string.Empty
&& GlobalSettings.ConfigurationStatus == string.Empty))
ServerOrder = 0,
},
new UserStep(umbracoContext.Application, status)
{
return true;
ServerOrder = 4,
},
new DatabaseConfigureStep(umbracoContext.Application)
{
ServerOrder = 1,
},
new DatabaseInstallStep(umbracoContext.Application)
{
ServerOrder = 2,
},
new DatabaseUpgradeStep(umbracoContext.Application)
{
ServerOrder = 3,
},
new StarterKitDownloadStep(status)
{
ServerOrder = 5,
},
new StarterKitInstallStep(status, umbracoContext.Application, umbracoContext.HttpContext)
{
ServerOrder = 6,
},
new StarterKitCleanupStep(status)
{
ServerOrder = 7,
},
new SetUmbracoVersionStep(umbracoContext.Application, umbracoContext.HttpContext)
{
ServerOrder = 8
}
});
return false;
}
return steps;
}
//public static bool IsNewInstall
//{
// get
// {
// var databaseSettings = ConfigurationManager.ConnectionStrings[GlobalSettings.UmbracoConnectionName];
// if (databaseSettings != null && (
// databaseSettings.ConnectionString.Trim() == string.Empty
// && databaseSettings.ProviderName.Trim() == string.Empty
// && GlobalSettings.ConfigurationStatus == string.Empty))
// {
// return true;
// }
// return false;
// }
//}
}
}

View File

@@ -10,8 +10,17 @@ namespace Umbraco.Web.Install.InstallSteps
[InstallSetupStep("StarterKitCleanup", "")]
internal class StarterKitCleanupStep : InstallSetupStep<object>
{
private readonly InstallStatus _status;
public StarterKitCleanupStep(InstallStatus status)
{
_status = status;
}
public override IDictionary<string, object> Execute(object model)
{
if (_status != InstallStatus.NewInstall) return null;
var installSteps = InstallStatusTracker.GetStatus();
//this step relies on the preious one completed - because it has stored some information we need
if (installSteps.Any(x => x.Key == "StarterKitDownload") == false)

View File

@@ -9,10 +9,19 @@ namespace Umbraco.Web.Install.InstallSteps
[InstallSetupStep("StarterKitDownload", "starterKit")]
internal class StarterKitDownloadStep : InstallSetupStep<Guid>
{
private readonly InstallStatus _status;
public StarterKitDownloadStep(InstallStatus status)
{
_status = status;
}
private const string RepoGuid = "65194810-1f85-11dd-bd0b-0800200c9a66";
public override IDictionary<string, object> Execute(Guid starterKitId)
{
if (_status != InstallStatus.NewInstall) return null;
var result = DownloadPackageFiles(starterKitId);
return new Dictionary<string, object>

View File

@@ -10,11 +10,13 @@ namespace Umbraco.Web.Install.InstallSteps
[InstallSetupStep("StarterKitInstall", "")]
internal class StarterKitInstallStep : InstallSetupStep<object>
{
private readonly InstallStatus _status;
private readonly ApplicationContext _applicationContext;
private readonly HttpContextBase _httContext;
public StarterKitInstallStep(ApplicationContext applicationContext, HttpContextBase httContext)
public StarterKitInstallStep(InstallStatus status, ApplicationContext applicationContext, HttpContextBase httContext)
{
_status = status;
_applicationContext = applicationContext;
_httContext = httContext;
}
@@ -22,6 +24,8 @@ namespace Umbraco.Web.Install.InstallSteps
public override IDictionary<string, object> Execute(object model)
{
if (_status != InstallStatus.NewInstall) return null;
var installSteps = InstallStatusTracker.GetStatus();
//this step relies on the preious one completed - because it has stored some information we need
if (installSteps.Any(x => x.Key == "StarterKitDownload") == false)

View File

@@ -12,10 +12,12 @@ namespace Umbraco.Web.Install.InstallSteps
internal class UserStep : InstallSetupStep<UserModel>
{
private readonly ApplicationContext _applicationContext;
private readonly InstallStatus _status;
public UserStep(ApplicationContext applicationContext)
public UserStep(ApplicationContext applicationContext, InstallStatus status)
{
_applicationContext = applicationContext;
_status = status;
}
private MembershipProvider CurrentProvider
@@ -67,5 +69,9 @@ namespace Umbraco.Web.Install.InstallSteps
return null;
}
public override string View
{
get { return _status == InstallStatus.NewInstall ? base.View : string.Empty; }
}
}
}

View File

@@ -18,9 +18,9 @@ namespace Umbraco.Web.Install.Models
/// </summary>
UpgradeWithoutToken,
/// <summary>
/// Used if the user presses f5 and is in the middle of an install
/// </summary>
InProgress
///// <summary>
///// Used if the user presses f5 and is in the middle of an install
///// </summary>
//InProgress
}
}