]> source.dussan.org Git - gitea.git/commitdiff
Fix #543
authorUnknwon <joe2010xtmf@163.com>
Mon, 24 Nov 2014 23:47:59 +0000 (18:47 -0500)
committerUnknwon <joe2010xtmf@163.com>
Mon, 24 Nov 2014 23:47:59 +0000 (18:47 -0500)
conf/app.ini
modules/middleware/auth.go
modules/setting/setting.go

index 6374c2423fa1bb31e293035542a1971eebaba1d3..e0620f31d6c1e7b08327fb76447b7d832ce6c756 100644 (file)
@@ -29,6 +29,8 @@ KEY_FILE = custom/https/key.pem
 STATIC_ROOT_PATH =
 ; Application level GZIP support
 ENABLE_GZIP = false
+; Landing page for non-logged users, can be "home" or "explore"
+LANDING_PAGE = home
 
 [database]
 ; Either "mysql", "postgres" or "sqlite3", it's your choice
index fc8e94bbd0db20d9fda545160bcf9e78ff841fa0..94bb1c14a4530645cae90429b05c5ac40dc95dc9 100644 (file)
@@ -29,6 +29,12 @@ func Toggle(options *ToggleOptions) macaron.Handler {
                        return
                }
 
+               // Checking non-logged users landing page.
+               if !ctx.IsSigned && ctx.Req.RequestURI == "/" && setting.LandingPageUrl != setting.LANDING_PAGE_HOME {
+                       ctx.Redirect(string(setting.LandingPageUrl))
+                       return
+               }
+
                // Redirect to dashboard if user tries to visit any non-login page.
                if options.SignOutRequire && ctx.IsSigned && ctx.Req.RequestURI != "/" {
                        ctx.Redirect(setting.AppSubUrl + "/")
index cf34c2edc63926bc6ebd39992294d2a2db028fd1..a775847c1fbbdb88415836097365a99bc9bc0952 100644 (file)
@@ -31,6 +31,13 @@ const (
        FCGI  Scheme = "fcgi"
 )
 
+type LandingPage string
+
+const (
+       LANDING_PAGE_HOME    LandingPage = "/"
+       LANDING_PAGE_EXPLORE LandingPage = "/explore"
+)
+
 var (
        // App settings.
        AppVer    string
@@ -48,6 +55,7 @@ var (
        CertFile, KeyFile  string
        StaticRootPath     string
        EnableGzip         bool
+       LandingPageUrl     LandingPage
 
        // Security settings.
        InstallLock          bool
@@ -197,6 +205,13 @@ func NewConfigContext() {
        LogRootPath = Cfg.MustValue("log", "ROOT_PATH", path.Join(workDir, "log"))
        EnableGzip = Cfg.MustBool("server", "ENABLE_GZIP")
 
+       switch Cfg.MustValue("server", "LANDING_PAGE", "home") {
+       case "explore":
+               LandingPageUrl = LANDING_PAGE_EXPLORE
+       default:
+               LandingPageUrl = LANDING_PAGE_HOME
+       }
+
        InstallLock = Cfg.MustBool("security", "INSTALL_LOCK")
        SecretKey = Cfg.MustValue("security", "SECRET_KEY")
        LogInRememberDays = Cfg.MustInt("security", "LOGIN_REMEMBER_DAYS")