diff --git a/src/Umbraco.Core/ApplicationContext.cs b/src/Umbraco.Core/ApplicationContext.cs
index 0cacb9fc09..8b78a6e676 100644
--- a/src/Umbraco.Core/ApplicationContext.cs
+++ b/src/Umbraco.Core/ApplicationContext.cs
@@ -203,11 +203,22 @@ namespace Umbraco.Core
}
///
- /// If the db is configured and there is a database context, but we are not 'configured' , then it means we are upgrading
+ /// If the db is configured, there is a database context and there is an umbraco schema, but we are not 'configured' , then it means we are upgrading
///
public bool IsUpgrading
{
- get { return IsConfigured == false && DatabaseContext != null && DatabaseContext.IsDatabaseConfigured; }
+ get
+ {
+ if (IsConfigured == false
+ && DatabaseContext != null
+ && DatabaseContext.IsDatabaseConfigured)
+ {
+ var schemaresult = DatabaseContext.ValidateDatabaseSchema();
+ if (schemaresult.ValidTables.Count > 0) return true;
+ }
+
+ return false;
+ }
}
///
diff --git a/src/Umbraco.Web/Security/Identity/AppBuilderExtensions.cs b/src/Umbraco.Web/Security/Identity/AppBuilderExtensions.cs
index c829efe593..c812384965 100644
--- a/src/Umbraco.Web/Security/Identity/AppBuilderExtensions.cs
+++ b/src/Umbraco.Web/Security/Identity/AppBuilderExtensions.cs
@@ -110,11 +110,15 @@ namespace Umbraco.Web.Security.Identity
/// Ensures that the UmbracoBackOfficeAuthenticationMiddleware is assigned to the pipeline
///
///
+ ///
///
- public static IAppBuilder UseUmbracoBackOfficeCookieAuthentication(this IAppBuilder app)
+ public static IAppBuilder UseUmbracoBackOfficeCookieAuthentication(this IAppBuilder app, ApplicationContext appContext)
{
if (app == null) throw new ArgumentNullException("app");
+ if (appContext == null) throw new ArgumentNullException("appContext");
+ //Don't proceed if the app is not ready
+ if (appContext.IsUpgrading == false && appContext.IsConfigured == false) return app;
app.UseCookieAuthentication(new UmbracoBackOfficeCookieAuthOptions(
UmbracoConfig.For.UmbracoSettings().Security,
@@ -142,10 +146,15 @@ namespace Umbraco.Web.Security.Identity
/// Umbraco back office configuration
///
///
+ ///
///
- public static IAppBuilder UseUmbracoBackOfficeExternalCookieAuthentication(this IAppBuilder app)
+ public static IAppBuilder UseUmbracoBackOfficeExternalCookieAuthentication(this IAppBuilder app, ApplicationContext appContext)
{
if (app == null) throw new ArgumentNullException("app");
+ if (appContext == null) throw new ArgumentNullException("appContext");
+
+ //Don't proceed if the app is not ready
+ if (appContext.IsUpgrading == false && appContext.IsConfigured == false) return app;
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
diff --git a/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs b/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs
index 4415016c9d..9aadb6fb42 100644
--- a/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs
+++ b/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs
@@ -32,8 +32,8 @@ namespace Umbraco.Web
//Ensure owin is configured for Umbraco back office authentication. If you have any front-end OWIN
// cookie configuration, this must be declared after it.
app
- .UseUmbracoBackOfficeCookieAuthentication()
- .UseUmbracoBackOfficeExternalCookieAuthentication();
+ .UseUmbracoBackOfficeCookieAuthentication(ApplicationContext.Current)
+ .UseUmbracoBackOfficeExternalCookieAuthentication(ApplicationContext.Current);
}
}
}