Refactoring cont.

This commit is contained in:
2025-04-23 09:44:19 +01:00
parent 5c3a847900
commit 2ce810a4dd
19 changed files with 117 additions and 150 deletions

View File

@@ -4,14 +4,15 @@ import (
"net/http"
"time"
httpHelpers "synlotto-website/helpers/http"
"synlotto-website/constants"
"synlotto-website/helpers"
)
func Auth(required bool) func(http.HandlerFunc) http.HandlerFunc {
return func(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
session, _ := helpers.GetSession(w, r)
session, _ := httpHelpers.GetSession(w, r)
_, ok := session.Values["user_id"].(int)
@@ -26,7 +27,7 @@ func Auth(required bool) func(http.HandlerFunc) http.HandlerFunc {
session.Options.MaxAge = -1
session.Save(r, w)
newSession, _ := helpers.GetSession(w, r)
newSession, _ := httpHelpers.GetSession(w, r)
newSession.Values["flash"] = "Your session has timed out."
newSession.Save(r, w)