Add user sessions and login
This isn't quite perfect, but gets much of the hard work done.
This commit is contained in:
parent
e311464b51
commit
486c148bf7
28 changed files with 1701 additions and 30 deletions
3
main.go
3
main.go
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue