// Package routes // Path: /internal/http/routes // File: accountroutes.go // // Purpose // Defines all /account route groups including: // // - Public authentication pages (login, signup) // - Protected session actions (logout) // - Auth-protected ticket management pages // // Responsibilities (as implemented here) // 1) PublicOnly guard on login/signup pages // 2) RequireAuth guard on logout and tickets pages // 3) Clean REST path structure for tickets ("/account/tickets") // // Notes // - AuthMiddleware must come before RequireAuth // - Ticket routes rely on authenticated user context package routes import ( accountHandler "synlotto-website/internal/handlers/account" accoutMessageHandler "synlotto-website/internal/handlers/account/messages" accountNotificationHandler "synlotto-website/internal/handlers/account/notifications" accountTicketHandler "synlotto-website/internal/handlers/account/tickets" "synlotto-website/internal/http/middleware" "synlotto-website/internal/platform/bootstrap" ) func RegisterAccountRoutes(app *bootstrap.App) { r := app.Router // Public account pages acc := r.Group("/account") acc.Use(middleware.PublicOnly()) { acc.GET("/login", accountHandler.LoginGet) acc.POST("/login", accountHandler.LoginPost) acc.GET("/signup", accountHandler.SignupGet) acc.POST("/signup", accountHandler.SignupPost) } // Auth-required account actions accAuth := r.Group("/account") accAuth.Use(middleware.AuthMiddleware(), middleware.RequireAuth()) { accAuth.POST("/logout", accountHandler.Logout) accAuth.GET("/logout", accountHandler.Logout) // optional } // Messages (auth-required) messages := r.Group("/account/messages") messages.Use(middleware.AuthMiddleware(), middleware.RequireAuth()) { messages.GET("/", accoutMessageHandler.List) messages.GET("/add", accoutMessageHandler.AddGet) messages.POST("/add", accoutMessageHandler.AddPost) messages.GET("/archived", accoutMessageHandler.ArchivedList) // renders archived.html messages.GET("/:id", accoutMessageHandler.ReadGet) // renders read.html } // Notifications (auth-required) notifications := r.Group("/account/notifications") notifications.Use(middleware.AuthMiddleware(), middleware.RequireAuth()) { notifications.GET("/", accountNotificationHandler.List) notifications.GET("/:id", accountNotificationHandler.ReadGet) // renders read.html } // Tickets (auth-required) tickets := r.Group("/account/tickets") tickets.Use(middleware.AuthMiddleware(), middleware.RequireAuth()) { tickets.GET("/", accountTicketHandler.List) // GET /account/tickets tickets.GET("/add", accountTicketHandler.AddGet) // GET /account/tickets/add tickets.POST("/add", accountTicketHandler.AddPost) // POST /account/tickets/add } }