コード例 #1
0
ファイル: AccountController.cs プロジェクト: marius310/bvcms
        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));
        }
コード例 #2
0
        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();
        }
コード例 #3
0
ファイル: Global.asax.cs プロジェクト: ilkerhalil/bvcms
        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;
        }
コード例 #4
0
ファイル: Global.asax.cs プロジェクト: SolidCharity/bvcms
        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;
        }
コード例 #5
0
        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;
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
ファイル: Global.asax.cs プロジェクト: chrisgundersen/bvcms
        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);
        }
コード例 #9
0
ファイル: Global.asax.cs プロジェクト: pwgoertz/bvcms
        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);
        }
コード例 #10
0
        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());
        }
コード例 #11
0
        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();
        }
コード例 #12
0
ファイル: Global.asax.cs プロジェクト: SolidCharity/bvcms
        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;
        }