Skip to content

Commit

Permalink
addressing broken session due to a recent change that wasn't properly…
Browse files Browse the repository at this point in the history
… tested, session is already created in the main config.go
  • Loading branch information
CyberRoute committed Sep 12, 2024
1 parent 1e96a8b commit 60085e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
8 changes: 3 additions & 5 deletions pkg/server/middleware/session.go
Original file line number Diff line number Diff line change
@@ -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)
}
3 changes: 1 addition & 2 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)

Expand Down

0 comments on commit 60085e9

Please sign in to comment.