mirror of
https://github.com/R0m1k3/FlowReader.git
synced 2026-10-11 17:28:05 +02:00
feat(story-1.4): add session-based authentication with login/logout
This commit is contained in:
1 parent
e186a4dd87
commit
d67e169a43
8 files changed
+446
-13
No files matched your search
+10
-2
@@ -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)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user