2018-03-27 10:04:07 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Web.Mvc;
|
2014-02-26 04:15:14 +11:00
|
|
|
|
using Umbraco.Core;
|
2019-12-19 15:53:50 +01:00
|
|
|
|
using Umbraco.Web.Composing;
|
2014-02-26 04:15:14 +11:00
|
|
|
|
using Umbraco.Core.Configuration;
|
2020-02-10 11:23:23 +01:00
|
|
|
|
using Umbraco.Core.IO;
|
2016-09-01 19:06:08 +02:00
|
|
|
|
using Umbraco.Core.Logging;
|
2020-03-17 10:28:03 +01:00
|
|
|
|
using Umbraco.Core.Runtime;
|
2019-01-29 23:05:59 +11:00
|
|
|
|
using Umbraco.Web.JavaScript;
|
2019-10-01 17:53:41 +02:00
|
|
|
|
using Umbraco.Web.Mvc;
|
2014-02-26 04:15:14 +11:00
|
|
|
|
using Umbraco.Web.Security;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Install.Controllers
|
|
|
|
|
|
{
|
2014-03-11 18:09:54 +11:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The MVC Installation controller
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// NOTE: All views must have their full paths as we do not have a custom view engine for the installation views!
|
|
|
|
|
|
/// </remarks>
|
2016-09-01 19:06:08 +02:00
|
|
|
|
[InstallAuthorize]
|
2014-02-26 04:15:14 +11:00
|
|
|
|
public class InstallController : Controller
|
|
|
|
|
|
{
|
2019-02-14 12:40:45 +01:00
|
|
|
|
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
2018-04-06 13:51:54 +10:00
|
|
|
|
private readonly InstallHelper _installHelper;
|
2016-09-01 19:06:08 +02:00
|
|
|
|
private readonly IRuntimeState _runtime;
|
|
|
|
|
|
private readonly ILogger _logger;
|
2018-04-06 13:51:54 +10:00
|
|
|
|
private readonly IGlobalSettings _globalSettings;
|
2019-11-19 23:15:11 +00:00
|
|
|
|
private readonly IUmbracoVersion _umbracoVersion;
|
2020-02-10 11:23:23 +01:00
|
|
|
|
private readonly IIOHelper _ioHelper;
|
2020-03-17 10:28:03 +01:00
|
|
|
|
private readonly IRuntimeMinifier _runtimeMinifier;
|
2014-02-26 04:15:14 +11:00
|
|
|
|
|
2020-03-17 10:28:03 +01:00
|
|
|
|
public InstallController(
|
|
|
|
|
|
IUmbracoContextAccessor umbracoContextAccessor,
|
|
|
|
|
|
InstallHelper installHelper,
|
|
|
|
|
|
IRuntimeState runtime,
|
|
|
|
|
|
ILogger logger,
|
|
|
|
|
|
IGlobalSettings globalSettings,
|
|
|
|
|
|
IUmbracoVersion umbracoVersion,
|
|
|
|
|
|
IIOHelper ioHelper,
|
|
|
|
|
|
IRuntimeMinifier runtimeMinifier)
|
2017-07-20 11:21:28 +02:00
|
|
|
|
{
|
2019-02-14 12:40:45 +01:00
|
|
|
|
_umbracoContextAccessor = umbracoContextAccessor;
|
2018-04-06 13:51:54 +10:00
|
|
|
|
_installHelper = installHelper;
|
2016-09-01 19:06:08 +02:00
|
|
|
|
_runtime = runtime;
|
2017-07-20 11:21:28 +02:00
|
|
|
|
_logger = logger;
|
2018-04-06 13:51:54 +10:00
|
|
|
|
_globalSettings = globalSettings;
|
2019-11-19 23:15:11 +00:00
|
|
|
|
_umbracoVersion = umbracoVersion;
|
2020-02-10 11:23:23 +01:00
|
|
|
|
_ioHelper = ioHelper;
|
2020-03-17 10:28:03 +01:00
|
|
|
|
_runtimeMinifier = runtimeMinifier;
|
2017-07-20 11:21:28 +02:00
|
|
|
|
}
|
2014-02-26 04:15:14 +11:00
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
2019-10-01 17:53:41 +02:00
|
|
|
|
[StatusCodeResult(System.Net.HttpStatusCode.ServiceUnavailable)]
|
2014-02-26 04:15:14 +11:00
|
|
|
|
public ActionResult Index()
|
|
|
|
|
|
{
|
2016-09-01 19:06:08 +02:00
|
|
|
|
if (_runtime.Level == RuntimeLevel.Run)
|
2020-01-21 17:03:46 -08:00
|
|
|
|
return Redirect(_globalSettings.UmbracoPath.EnsureEndsWith('/'));
|
2014-02-27 10:16:30 +01:00
|
|
|
|
|
2016-09-01 19:06:08 +02:00
|
|
|
|
if (_runtime.Level == RuntimeLevel.Upgrade)
|
2015-06-22 16:22:47 +02:00
|
|
|
|
{
|
2020-03-17 15:45:34 +01:00
|
|
|
|
// Update ClientDependency version and delete its temp directories to make sure we get fresh caches
|
|
|
|
|
|
_runtimeMinifier.Reset();
|
|
|
|
|
|
|
2019-02-14 12:40:45 +01:00
|
|
|
|
var result = _umbracoContextAccessor.UmbracoContext.Security.ValidateCurrentUser(false);
|
2014-02-26 04:15:14 +11:00
|
|
|
|
|
|
|
|
|
|
switch (result)
|
|
|
|
|
|
{
|
|
|
|
|
|
case ValidateRequestAttempt.FailedNoPrivileges:
|
2015-06-22 16:22:47 +02:00
|
|
|
|
case ValidateRequestAttempt.FailedNoContextId:
|
2020-01-21 17:03:46 -08:00
|
|
|
|
return Redirect(_globalSettings.UmbracoPath + "/AuthorizeUpgrade?redir=" + Server.UrlEncode(Request.RawUrl));
|
2014-02-26 04:15:14 +11:00
|
|
|
|
}
|
2015-06-22 16:22:47 +02:00
|
|
|
|
}
|
2014-02-26 16:01:31 +01:00
|
|
|
|
|
2016-09-01 19:06:08 +02:00
|
|
|
|
// gen the install base url
|
2019-03-28 12:10:59 +01:00
|
|
|
|
ViewData.SetInstallApiBaseUrl(Url.GetUmbracoApiService("GetSetup", "InstallApi", "UmbracoInstall").TrimEnd("GetSetup"));
|
2016-09-01 19:06:08 +02:00
|
|
|
|
|
|
|
|
|
|
// get the base umbraco folder
|
2020-02-10 11:23:23 +01:00
|
|
|
|
ViewData.SetUmbracoBaseFolder(_ioHelper.ResolveUrl(_globalSettings.UmbracoPath));
|
2014-02-26 16:01:31 +01:00
|
|
|
|
|
2018-04-06 13:51:54 +10:00
|
|
|
|
_installHelper.InstallStatus(false, "");
|
2014-04-07 16:08:34 +02:00
|
|
|
|
|
2016-09-01 19:06:08 +02:00
|
|
|
|
// always ensure full path (see NOTE in the class remarks)
|
2020-03-17 16:26:56 +01:00
|
|
|
|
return View(_ioHelper.BackOfficePath.EnsureEndsWith('/') + "install/views/index.cshtml");
|
2014-02-26 04:15:14 +11:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|