From 60085e95fb2a843ddc4590b15b66343e435cb226 Mon Sep 17 00:00:00 2001 From: CyberRoute Date: Thu, 12 Sep 2024 15:23:46 +0200 Subject: [PATCH] addressing broken session due to a recent change that wasn't properly tested, session is already created in the main config.go --- pkg/server/middleware/session.go | 8 +++----- pkg/server/server.go | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/server/middleware/session.go b/pkg/server/middleware/session.go index 465411f..f88cc1d 100644 --- a/pkg/server/middleware/session.go +++ b/pkg/server/middleware/session.go @@ -1,13 +1,11 @@ package middleware import ( - "github.com/alexedwards/scs/v2" "net/http" + "github.com/CyberRoute/bruter/pkg/config" ) -var session *scs.SessionManager - // SessionLoad loads and saves the session on every request -func SessionLoad(next http.Handler) http.Handler { - return session.LoadAndSave(next) +func SessionLoad(app *config.AppConfig, next http.Handler) http.Handler { + return app.Session.LoadAndSave(next) } diff --git a/pkg/server/server.go b/pkg/server/server.go index e6a89a1..066212d 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -2,7 +2,6 @@ package server import ( "github.com/CyberRoute/bruter/pkg/config" - midd "github.com/CyberRoute/bruter/pkg/server/middleware" "github.com/CyberRoute/bruter/pkg/server/routes" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" @@ -12,7 +11,7 @@ func NewServer(app *config.AppConfig) *chi.Mux { mux := chi.NewRouter() mux.Use(middleware.Recoverer) - mux.Use(midd.SessionLoad) + mux.Use(app.Session.LoadAndSave) sc := NewConfigServer(app)