From 81a44e4cd0c4f4c2310b59624748ba0df9fcbe87 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 28 Dec 2014 20:40:35 +0800 Subject: [PATCH] fix API changes --- .gopmfile | 7 +++---- cmd/web.go | 5 +---- modules/setting/setting.go | 12 ++---------- routers/admin/admin.go | 1 - templates/admin/config.tmpl | 4 +--- 5 files changed, 7 insertions(+), 22 deletions(-) diff --git a/.gopmfile b/.gopmfile index 49b4171550c6..7fb407d16585 100644 --- a/.gopmfile +++ b/.gopmfile @@ -6,9 +6,8 @@ github.com/beego/memcache = commit:2aea774416 github.com/beego/redigo = commit:856744a0d5 github.com/Unknwon/cae = commit:2e70a1351b github.com/Unknwon/com = -github.com/Unknwon/goconfig = commit:0f8d8dc1c0 github.com/Unknwon/i18n = commit:aec5f77857 -github.com/Unknwon/macaron = commit:3d307c1232 +github.com/Unknwon/macaron = github.com/codegangsta/cli = commit:7381bc4e62 github.com/go-sql-driver/mysql = commit:8111ee3ec3 github.com/go-xorm/core = commit:3e0fa232ab @@ -20,9 +19,9 @@ github.com/macaron-contrib/binding = github.com/macaron-contrib/cache = commit:0bb9e6c9ef github.com/macaron-contrib/captcha = commit:3567dc48b8 github.com/macaron-contrib/csrf = commit:422b79675c -github.com/macaron-contrib/i18n = commit:184bb832f2 +github.com/macaron-contrib/i18n = github.com/macaron-contrib/oauth2 = commit:8f394c3629 -github.com/macaron-contrib/session = commit:f00d48fd4f +github.com/macaron-contrib/session = github.com/macaron-contrib/toolbox = commit:57127bcc89 github.com/mattn/go-sqlite3 = commit:a80c27ba33 github.com/nfnt/resize = commit:581d15cb53 diff --git a/cmd/web.go b/cmd/web.go index 2251ea921845..56df5fe721cb 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -133,10 +133,7 @@ func newMacaron() *macaron.Macaron { m.Use(captcha.Captchaer(captcha.Options{ SubURL: setting.AppSubUrl, })) - m.Use(session.Sessioner(session.Options{ - Provider: setting.SessionProvider, - Config: *setting.SessionConfig, - })) + m.Use(session.Sessioner(setting.SessionConfig)) m.Use(csrf.Csrfer(csrf.Options{ Secret: setting.SecretKey, SetCookie: true, diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 76e1ab76965e..cda50b8e984a 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -104,8 +104,7 @@ var ( EnableMemcache bool // Session settings. - SessionProvider string - SessionConfig *session.Config + SessionConfig session.Options // Git settings. MaxGitDiffLines int @@ -412,22 +411,15 @@ func newCacheService() { } func newSessionService() { - SessionProvider = Cfg.MustValueRange("session", "PROVIDER", "memory", + SessionConfig.Provider = Cfg.MustValueRange("session", "PROVIDER", "memory", []string{"memory", "file", "redis", "mysql"}) - - SessionConfig = new(session.Config) SessionConfig.ProviderConfig = strings.Trim(Cfg.MustValue("session", "PROVIDER_CONFIG"), "\" ") SessionConfig.CookieName = Cfg.MustValue("session", "COOKIE_NAME", "i_like_gogits") SessionConfig.CookiePath = AppSubUrl SessionConfig.Secure = Cfg.MustBool("session", "COOKIE_SECURE") - SessionConfig.EnableSetCookie = Cfg.MustBool("session", "ENABLE_SET_COOKIE", true) SessionConfig.Gclifetime = Cfg.MustInt64("session", "GC_INTERVAL_TIME", 86400) SessionConfig.Maxlifetime = Cfg.MustInt64("session", "SESSION_LIFE_TIME", 86400) - if SessionProvider == "file" { - os.MkdirAll(path.Dir(SessionConfig.ProviderConfig), os.ModePerm) - } - log.Info("Session Service Enabled") } diff --git a/routers/admin/admin.go b/routers/admin/admin.go index 99bae8819a4b..563a9cdc41f9 100644 --- a/routers/admin/admin.go +++ b/routers/admin/admin.go @@ -202,7 +202,6 @@ func Config(ctx *middleware.Context) { ctx.Data["CacheInternal"] = setting.CacheInternal ctx.Data["CacheConn"] = setting.CacheConn - ctx.Data["SessionProvider"] = setting.SessionProvider ctx.Data["SessionConfig"] = setting.SessionConfig ctx.Data["PictureService"] = setting.PictureService diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl index 3ccb106bc4e7..9dd25081ace4 100644 --- a/templates/admin/config.tmpl +++ b/templates/admin/config.tmpl @@ -169,13 +169,11 @@
{{.i18n.Tr "admin.config.session_provider"}}
-
{{.SessionProvider}}
+
{{.SessionConfig.Provider}}
{{.i18n.Tr "admin.config.provider_config"}}
{{.SessionConfig.ProviderConfig}}
{{.i18n.Tr "admin.config.cookie_name"}}
{{.SessionConfig.CookieName}}
-
{{.i18n.Tr "admin.config.enable_set_cookie"}}
-
{{.i18n.Tr "admin.config.gc_interval_time"}}
{{.SessionConfig.Gclifetime}} {{.i18n.Tr "tool.raw_seconds"}}
{{.i18n.Tr "admin.config.session_life_time"}}