1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00

Pass in a session store so they can be shared

This commit is contained in:
Daniel Heath 2018-04-28 12:09:08 +10:00
parent ff5c100cf8
commit ede4d1fba3

View File

@ -40,7 +40,7 @@ type Site struct {
DefaultPassword string DefaultPassword string
Debounce int Debounce int
Diary bool Diary bool
Secret string SessionStore sessions.Store
SecretCode string SecretCode string
AllowInsecure bool AllowInsecure bool
HotTemplateReloading bool HotTemplateReloading bool
@ -88,7 +88,7 @@ func Serve(
defaultPassword, defaultPassword,
debounce, debounce,
diary, diary,
secret, sessions.NewCookieStore([]byte(secret)),
secretCode, secretCode,
allowInsecure, allowInsecure,
hotTemplateReloading, hotTemplateReloading,
@ -130,8 +130,7 @@ func (s Site) Router() *gin.Engine {
router.HTMLRender = loadTemplates("index.tmpl") router.HTMLRender = loadTemplates("index.tmpl")
} }
store := sessions.NewCookieStore([]byte(s.Secret)) router.Use(sessions.Sessions(s.PathToData, s.SessionStore))
router.Use(sessions.Sessions("mysession", store))
if s.SecretCode != "" { if s.SecretCode != "" {
cfg := &secretRequired.Config{ cfg := &secretRequired.Config{
Secret: s.SecretCode, Secret: s.SecretCode,