Add user sessions and login

This isn't quite perfect, but gets much of the hard work done.
This commit is contained in:
Eli Ribble 2025-11-05 17:15:33 +00:00
parent e311464b51
commit 486c148bf7
No known key found for this signature in database
28 changed files with 1701 additions and 30 deletions

View file

@ -7,6 +7,7 @@ import (
"os"
"time"
"github.com/alexedwards/scs/pgxstore"
"github.com/alexedwards/scs/v2"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
@ -49,6 +50,7 @@ func main() {
os.Exit(2)
}
sessionManager = scs.New()
sessionManager.Store = pgxstore.New(PGInstance.PGXPool)
sessionManager.Lifetime = 24 * time.Hour
r := chi.NewRouter()
@ -56,6 +58,7 @@ func main() {
r.Use(sessionManager.LoadAndSave)
r.Get("/", getRoot)
r.Post("/signin", postSignin)
r.Get("/signup", getSignup)
r.Post("/signup", postSignup)
r.Get("/favicon.ico", getFavicon)