Release v0.20: регистрация, авторизация, личный кабинет

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
shop
2026-05-16 17:31:56 +03:00
parent 4ea2b429b3
commit b3e3a06858
23 changed files with 981 additions and 27 deletions
+13 -1
View File
@@ -11,6 +11,7 @@ import (
"syscall"
"time"
"shop/internal/auth"
"shop/internal/check"
"shop/internal/config"
"shop/internal/database"
@@ -49,9 +50,16 @@ func main() {
log.Fatalf("templates: %v", err)
}
users := repository.NewUserRepository(pool)
sessions := repository.NewSessionRepository(pool)
authSvc := auth.NewService(users, sessions, cfg.SessionTTL, cfg.CookieSecure)
pages := handlers.NewPages(tmpl, authSvc)
products := repository.NewProductRepository(pool)
home := handlers.NewHomeHandler(products, tmpl)
home := handlers.NewHomeHandler(products, pages)
health := handlers.NewHealthHandler(pool)
authH := handlers.NewAuthHandler(pages, authSvc)
account := handlers.NewAccountHandler(pages, authSvc)
staticSub, err := fs.Sub(web.StaticFS, "static")
if err != nil {
@@ -63,6 +71,10 @@ func main() {
mux.HandleFunc("GET /health", health.Health)
mux.HandleFunc("GET /version", health.Version)
mux.Handle("GET /", home)
mux.HandleFunc("/register", authH.Register)
mux.HandleFunc("/login", authH.Login)
mux.HandleFunc("POST /logout", authH.Logout)
mux.HandleFunc("/account", account.Account)
srv := &http.Server{
Addr: cfg.HTTPAddr,