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
1 changed files with 3 additions and 4 deletions

View File

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