public override bool RequiresExecution(UserModel model) { //now we have to check if this is really a new install, the db might be configured and might contain data var databaseSettings = ConfigurationManager.ConnectionStrings[Constants.System.UmbracoConnectionName]; //if there's already a version then there should def be a user but in some cases someone may have // left a version number in there but cleared out their db conn string, in that case, it's really a new install. if (GlobalSettings.ConfigurationStatus.IsNullOrWhiteSpace() == false && databaseSettings != null) { return(false); } if (_applicationContext.DatabaseContext.IsConnectionStringConfigured(databaseSettings) && _applicationContext.DatabaseContext.IsDatabaseConfigured) { //check if we have the default user configured already var result = _applicationContext.DatabaseContext.Database.ExecuteScalar <int>( "SELECT COUNT(*) FROM umbracoUser WHERE id=0 AND userPassword='******'"); if (result == 1) { //the user has not been configured return(true); } return(false); } else { // In this one case when it's a brand new install and nothing has been configured, make sure the // back office cookie is cleared so there's no old cookies lying around causing problems _http.ExpireCookie(UmbracoConfig.For.UmbracoSettings().Security.AuthCookieName); return(true); } }
public override bool RequiresExecution(UserModel model) { var installState = GetInstallState(); if (installState.HasFlag(InstallState.Unknown)) { // In this one case when it's a brand new install and nothing has been configured, make sure the // back office cookie is cleared so there's no old cookies lying around causing problems _http.ExpireCookie(Current.Configs.Settings().Security.AuthCookieName); } return(installState.HasFlag(InstallState.Unknown) || !installState.HasFlag(InstallState.HasNonDefaultUser)); }
public override bool RequiresExecution(UserModel model) { //now we have to check if this is really a new install, the db might be configured and might contain data var databaseSettings = ConfigurationManager.ConnectionStrings[Constants.System.UmbracoConnectionName]; //if there's already a version then there should def be a user but in some cases someone may have // left a version number in there but cleared out their db conn string, in that case, it's really a new install. if (_globalSettings.ConfigurationStatus.IsNullOrWhiteSpace() == false && databaseSettings != null) { return(false); } if (_databaseBuilder.IsConnectionStringConfigured(databaseSettings) && _databaseBuilder.IsDatabaseConfigured) { return(_databaseBuilder.HasSomeNonDefaultUser() == false); } // In this one case when it's a brand new install and nothing has been configured, make sure the // back office cookie is cleared so there's no old cookies lying around causing problems _http.ExpireCookie(Current.Configs.Settings().Security.AuthCookieName); return(true); }
/// <summary> /// Copies data from a request cookie to view data and then clears the cookie in the response /// </summary> /// <param name="viewData"></param> /// <param name="httpContext"></param> /// <param name="cookieName"></param> /// <returns></returns> /// <remarks> /// <para> /// This is similar to TempData but in some cases we cannot use TempData which relies on the temp data provider and session. /// The cookie value can either be a simple string value /// </para> /// </remarks> internal static bool FromBase64CookieData <T>(this ViewDataDictionary viewData, HttpContextBase httpContext, string cookieName) { var hasCookie = httpContext.Request.HasCookie(cookieName); if (!hasCookie) { return(false); } // get the cookie value var cookieVal = httpContext.Request.GetCookieValue(cookieName); if (cookieVal == null) { return(false); } // ensure the cookie is expired (must be done after reading the value) httpContext.ExpireCookie(cookieName); if (cookieVal.IsNullOrWhiteSpace()) { return(false); } try { var decoded = Encoding.UTF8.GetString(Convert.FromBase64String(System.Net.WebUtility.UrlDecode(cookieVal))); // deserialize to T and store in viewdata viewData[cookieName] = JsonConvert.DeserializeObject <T>(decoded); return(true); } catch (Exception) { return(false); } }