User specific lottery ticket creation
This commit is contained in:
@@ -1,7 +1,28 @@
|
||||
// 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 (
|
||||
accountHandlers "synlotto-website/internal/handlers/account"
|
||||
accountTicketHandlers "synlotto-website/internal/handlers/account/tickets"
|
||||
|
||||
"synlotto-website/internal/http/middleware"
|
||||
"synlotto-website/internal/platform/bootstrap"
|
||||
@@ -10,6 +31,7 @@ import (
|
||||
func RegisterAccountRoutes(app *bootstrap.App) {
|
||||
r := app.Router
|
||||
|
||||
// Public account pages
|
||||
acc := r.Group("/account")
|
||||
acc.Use(middleware.PublicOnly())
|
||||
{
|
||||
@@ -19,9 +41,20 @@ func RegisterAccountRoutes(app *bootstrap.App) {
|
||||
acc.POST("/signup", accountHandlers.SignupPost)
|
||||
}
|
||||
|
||||
// Protected logout
|
||||
// Auth-required account actions
|
||||
accAuth := r.Group("/account")
|
||||
accAuth.Use(middleware.AuthMiddleware(), middleware.RequireAuth())
|
||||
accAuth.POST("/logout", accountHandlers.Logout)
|
||||
accAuth.GET("/logout", accountHandlers.Logout) //ToDo: keep if you still support GET?
|
||||
{
|
||||
accAuth.POST("/logout", accountHandlers.Logout)
|
||||
accAuth.GET("/logout", accountHandlers.Logout) // optional
|
||||
}
|
||||
|
||||
// Tickets (auth-required)
|
||||
tickets := r.Group("/account/tickets")
|
||||
tickets.Use(middleware.AuthMiddleware(), middleware.RequireAuth())
|
||||
{
|
||||
tickets.GET("/", accountTicketHandlers.List) // GET /account/tickets
|
||||
tickets.GET("/add", accountTicketHandlers.AddGet) // GET /account/tickets/add
|
||||
tickets.POST("/add", accountTicketHandlers.AddPost) // POST /account/tickets/add
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user