From 68a6169bc309b42aca22e93b4b741e04f6808c22 Mon Sep 17 00:00:00 2001 From: Leon Mika Date: Sun, 30 Mar 2025 11:00:35 +1100 Subject: [PATCH] Bumped the cookie age to 30 days --- handlers/auth.go | 9 +++++++-- main.go | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/handlers/auth.go b/handlers/auth.go index 1420282..ba0231e 100644 --- a/handlers/auth.go +++ b/handlers/auth.go @@ -8,6 +8,10 @@ import ( "lmika.dev/lmika/hugo-cms/services/users" ) +const ( + authCookieAge = 30 * 24 * 3600 // 30 days +) + type AuthHandler struct { UserService *users.Service } @@ -37,8 +41,9 @@ func (h *AuthHandler) Login(c fiber.Ctx) error { } c.Cookie(&fiber.Cookie{ - Name: models.AuthCookieName, - Value: string(bts), + Name: models.AuthCookieName, + Value: string(bts), + MaxAge: authCookieAge, }) return c.Redirect().To("/") } diff --git a/main.go b/main.go index 09934ae..eaebcf2 100644 --- a/main.go +++ b/main.go @@ -115,7 +115,9 @@ func main() { Views: tmplEngine, PassLocalsToViews: true, }) - app.Use(encryptcookie.New(encryptcookie.Config{Key: cfg.EncryptedCookieKey})) + app.Use(encryptcookie.New(encryptcookie.Config{ + Key: cfg.EncryptedCookieKey, + })) app.Use("/assets", static.New("", static.Config{ FS: assets.FS,