public ActionResult LogOn(string returnUrl) { var r = DbUtil.CheckDatabaseExists(Util.CmsHost); var redirect = ViewExtensions2.DatabaseErrorUrl(r); if (redirect != null) { return(Redirect(redirect)); } var user = AccountModel.GetValidToken(Request.QueryString["otltoken"]); if (user.HasValue()) { FormsAuthentication.SetAuthCookie(user, false); AccountModel.SetUserInfo(user, Session); if (returnUrl.HasValue() && Url.IsLocalUrl(returnUrl)) { return(Redirect(returnUrl)); } return(Redirect("/")); } var m = new AccountInfo { ReturnUrl = returnUrl }; return(View(m)); }
protected void Session_Start(object sender, EventArgs e) { //stackoverflow.com/questions/904952 string sessionId = Session.SessionID; if (ShouldBypassProcessing()) { return; } if (User.Identity.IsAuthenticated) { var host = CMSDataContext.GetHost(new HttpContextWrapper(Context)); var r = DbUtil.CheckDatabaseExists($"CMS_{host}"); var redirect = ViewExtensions2.DatabaseErrorUrl(r); if (redirect != null) { Response.Redirect(redirect); return; } var db = CMSDataContext.Create(HttpContextFactory.Current); var idb = CMSImageDataContext.Create(HttpContextFactory.Current); HttpContextFactory.Current.Items["SessionProvider"] = new CMSShared.Session.CmsSessionProvider(db); AccountModel.SetUserInfo(db, idb, Util.UserName); } Util.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); }
protected void Session_Start(object sender, EventArgs e) { if (ShouldBypassProcessing()) { return; } if (Util.Host.StartsWith("direct")) { return; } if (User.Identity.IsAuthenticated) { var r = DbUtil.CheckDatabaseExists(Util.CmsHost); var redirect = ViewExtensions2.DatabaseErrorUrl(r); if (redirect != null) { Response.Redirect(redirect); return; } AccountModel.SetUserInfo(Util.UserName, Session); } Util.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); Util.SessionStarting = true; }
protected void Session_Start(object sender, EventArgs e) { if (ShouldBypassProcessing()) { return; } if (Request.Url.Authority.StartsWith("direct")) { return; } if (User.Identity.IsAuthenticated) { var host = CMSDataContext.GetHost(new HttpContextWrapper(Context)); var r = DbUtil.CheckDatabaseExists($"CMS_{host}"); var redirect = ViewExtensions2.DatabaseErrorUrl(r); if (redirect != null) { Response.Redirect(redirect); return; } var db = CMSDataContext.Create(HttpContextFactory.Current); var idb = CMSImageDataContext.Create(HttpContextFactory.Current); AccountModel.SetUserInfo(db, idb, Util.UserName); } Util.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); Util.SessionStarting = true; }
protected void Session_Start(object sender, EventArgs e) { if (ShouldBypassProcessing()) { return; } if (Util.Host.StartsWith("direct")) { return; } if (User.Identity.IsAuthenticated) { var r = DbUtil.CheckDatabaseExists(Util.CmsHost); var redirect = ViewExtensions2.DatabaseErrorUrl(r); if (redirect != null) { Response.Redirect(redirect); return; } AccountModel.SetUserInfo(Util.UserName, Session); CmsController.ConvertRegistration(); // for non hosted churches, we will eventually remove this } Util.SysFromEmail = ConfigurationManager.AppSettings["sysfromemail"]; Util.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); Util.SessionStarting = true; }
protected void Application_BeginRequest(object sender, EventArgs e) { if (ShouldBypassProcessing()) { return; } if (Util.AppOffline) { Response.Redirect("/Errors/AppOffline.htm"); return; } // MiniProfiler.Start(); var r = DbUtil.CheckDatabaseExists(Util.CmsHost); var redirect = ViewExtensions2.DatabaseErrorUrl(r); #if DEBUG if (r == DbUtil.CheckDatabaseResult.ServerNotFound) { Response.Redirect(redirect); return; } if (r == DbUtil.CheckDatabaseResult.DatabaseDoesNotExist && HttpContext.Current.Request.Url.LocalPath.EndsWith("/")) { var ret = DbUtil.CreateDatabase(); if (ret.HasValue()) { Response.Redirect($"/Errors/DatabaseCreationError.aspx?error={HttpUtility.UrlEncode(ret)}"); return; } } #else if (redirect != null) { Response.Redirect(redirect); return; } #endif try { Util.AdminMail = DbUtil.Db.Setting("AdminMail", ""); Util.DateSimulation = DbUtil.Db.Setting("UseDateSimulation"); } catch (SqlException) { throw; //Response.Redirect($"/Errors/DatabaseNotInitialized.aspx?dbname={Util.Host}"); } var cul = DbUtil.Db.Setting("Culture", "en-US"); Util.Culture = cul; Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cul); }
protected void Application_BeginRequest(object sender, EventArgs e) { var url = Request.Url.OriginalString; if (url.Contains("/Errors/") || url.Contains("healthcheck.txt")) { return; } if (Util.AppOffline) { Response.Redirect("/Errors/AppOffline.htm"); return; } var r = DbUtil.CheckDatabaseExists(Util.CmsHost); var redirect = ViewExtensions2.DatabaseErrorUrl(r); #if DEBUG if (r == DbUtil.CheckDatabaseResult.ServerNotFound) { Response.Redirect(redirect); return; } if (r == DbUtil.CheckDatabaseResult.DatabaseDoesNotExist && HttpContext.Current.Request.Url.LocalPath.EndsWith("/")) { var ret = DbUtil.CreateDatabase(); if (ret.HasValue()) { Response.Redirect("/Errors/DatabaseCreationError.aspx?error=" + HttpUtility.UrlEncode(ret)); return; } } #else if (redirect != null) { Response.Redirect(redirect); return; } #endif try { Util.AdminMail = DbUtil.Db.Setting("AdminMail", ""); } catch (SqlException) { Response.Redirect("/Errors/DatabaseNotInitialized.aspx?dbname=" + Util.Host); } var cul = DbUtil.Db.Setting("Culture", "en-US"); Util.Culture = cul; Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cul); }
protected void Application_BeginRequest(object sender, EventArgs e) { var url = Request.Url.OriginalString; if (url.Contains("/Errors/") || url.Contains("healthcheck.txt")) { return; } if (Util.AppOffline) { Response.Redirect("/Errors/AppOffline.htm"); return; } if (!DbUtil.CmsDatabaseExists()) { #if DEBUG var r = DbUtil.CheckDatabaseExists(Util.Host); if (r == DbUtil.CheckDatabaseResult.ServerNotFound) { Response.Redirect("/Errors/DatabaseServerNotFound.aspx?server=" + Util.DbServer); return; } var ret = DbUtil.CreateDatabase(); if (ret.HasValue()) { Response.Redirect("/Errors/DatabaseCreationError.aspx?error=" + HttpUtility.UrlEncode(ret)); return; } #else Response.Redirect("/Errors/DatabaseNotFound.aspx?dbname=" + Util.Host); return; #endif } try { Util.AdminMail = DbUtil.Db.Setting("AdminMail", ""); } catch (SqlException) { Response.Redirect("/Errors/DatabaseNotInitialized.aspx?dbname=" + Util.Host); } var cul = DbUtil.Db.Setting("Culture", "en-US"); Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cul); }
private bool HandleBvcmsDomain() { var bvcms = "bvcms.com"; if (Request.Url.Host.Contains(bvcms, true)) { var url = Request.Url.OriginalString; var dbExists = DbUtil.CheckDatabaseExists(Util.CmsHost) == DbUtil.CheckDatabaseResult.DatabaseExists; var newBaseUrl = "tpsdb.com"; if (!dbExists) { newBaseUrl = "touchpointsoftware.com"; bvcms = Request.Url.Host; } Response.RedirectPermanent(url.Replace(bvcms, newBaseUrl)); CompleteRequest(); return(true); } return(false); }
public ActionResult LogOn() { var ret = DbUtil.CheckDatabaseExists(Util.Host); switch (ret) { case DbUtil.CheckDatabaseResult.DatabaseExists: break; case DbUtil.CheckDatabaseResult.DatabaseDoesNotExist: return(Redirect("/Errors/DatabaseNotFound.aspx?dbname=" + Util.Host)); case DbUtil.CheckDatabaseResult.ServerNotFound: return(Redirect("/Errors/DatabaseServerNotFound.aspx?server=" + Util.DbServer)); } if (DbUtil.Db.Roles.Any(rr => rr.RoleName == "disabled")) { return(Content("Site is disabled, contact {0} for help".Fmt(Util.SendErrorsTo()[0].Address))); } string user = AccountModel.GetValidToken(Request.QueryString["otltoken"]); if (user.HasValue()) { FormsAuthentication.SetAuthCookie(user, false); AccountModel.SetUserInfo(user, Session); var returnUrl = Request.QueryString["returnUrl"]; if (returnUrl.HasValue()) { return(Redirect(returnUrl)); } return(Redirect("/")); } return(View()); }
protected void Session_Start(object sender, EventArgs e) { //DbUtil.LogActivity("Session Starting"); if (Util.Host.StartsWith("direct")) { return; } if (User.Identity.IsAuthenticated) { var r = DbUtil.CheckDatabaseExists(Util.CmsHost); var redirect = ViewExtensions2.DatabaseErrorUrl(r); if (redirect != null) { Response.Redirect(redirect); return; } Models.AccountModel.SetUserInfo(Util.UserName, Session); } Util.SysFromEmail = ConfigurationManager.AppSettings["sysfromemail"]; Util.Version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); Util.SessionStarting = true; LogBrowser(); }
protected void Application_BeginRequest(object sender, EventArgs e) { if (IsRackspaceMonitoring()) { Response.StatusCode = (int)HttpStatusCode.OK; Response.ContentType = "text/plain"; Response.Write("OK"); CompleteRequest(); return; } if (HandleBvcmsDomain()) { return; } if (ShouldBypassProcessing()) { return; } Response.Headers?.Remove("Server"); if (Util.AppOffline) { Response.Redirect("/Errors/AppOffline.htm"); return; } var host = CMSDataContext.GetHost(new HttpContextWrapper(Context)); var r = DbUtil.CheckDatabaseExists($"CMS_{host}"); var redirect = ViewExtensions2.DatabaseErrorUrl(r); if (Util.IsDebug()) { if (r == DbUtil.CheckDatabaseResult.ServerNotFound) { Response.Redirect(redirect); return; } if (r == DbUtil.CheckDatabaseResult.DatabaseDoesNotExist && "localhost".Equal(Request.Url.Host)) { var ret = DbUtil.CreateDatabase(host); if (ret.HasValue()) { Response.Redirect($"/Errors/DatabaseCreationError.aspx?error={HttpUtility.UrlEncode(ret)}"); return; } } } else { if (redirect != null) { Response.Redirect(redirect); return; } } var db = CMSDataContext.Create(new HttpContextWrapper(Context)); Util.AdminMail = db.Setting("AdminMail", ""); Util.DateSimulation = db.Setting("UseDateSimulation"); var cul = db.Setting("Culture", "en-US"); Util.Culture = cul; Thread.CurrentThread.CurrentUICulture = new CultureInfo(cul); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cul); var checkip = ConfigurationManager.AppSettings["CheckIp"]; if (Util.IsHosted && checkip.HasValue()) { if (1 == db.Connection.ExecuteScalar <int>(checkip, new { ip = Request.UserHostAddress })) { Response.Redirect("/Errors/AccessDenied.htm"); } } ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; }