feat(story-1.4): add session-based authentication with login/logout

This commit is contained in:
Michael committed 2026-02-04 14:44:48 +01:00
1 parent e186a4dd87
commit d67e169a43
8 files changed
+446 -13

No files matched your search

+10 -2
View File
@@ -37,9 +37,10 @@ func main() {
// Initialize repositories
userRepo := repository.NewUserRepository(pool)
sessionRepo := repository.NewSessionRepository(pool)
// Initialize services
authService := service.NewAuthService(userRepo)
authService := service.NewAuthService(userRepo, sessionRepo)
// Initialize handlers
authHandler := handler.NewAuthHandler(authService)
@@ -72,9 +73,16 @@ func main() {
w.Write([]byte(`{"message":"FlowReader API v1"}`))
})
// Auth routes
// Auth routes (public)
r.Route("/auth", func(r chi.Router) {
r.Post("/register", authHandler.Register)
r.Post("/login", authHandler.Login)
r.Post("/logout", authHandler.Logout)
})
// User routes
r.Route("/users", func(r chi.Router) {
r.Get("/me", authHandler.Me)
})
})