Add multi-user support with export feature

- New users table (migration 004) with user_id on exercises, training_sets, sessions
- User CRUD endpoints (GET/POST /api/v1/users, DELETE /api/v1/users/{id})
- All existing endpoints scoped to X-User-ID header
- CSV export endpoint (GET /api/v1/export) for completed sessions
- UserGate in PageShell: blocks app until a user is selected
- Settings page for managing users (create, switch, delete)
- BottomNav/Sidebar updated with settings navigation
- Fix: nil pointer panic in handleDeleteUser on success path
- Fix: export download now uses fetch with X-User-ID header instead of window.location.href

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Christoph K.
2026-03-21 23:55:51 +01:00
parent bff85908c3
commit a954f2c59d
24 changed files with 793 additions and 95 deletions

View File

@@ -0,0 +1,31 @@
package model
import (
"errors"
"strings"
"time"
)
// User repräsentiert einen Nutzer der Applikation.
type User struct {
ID int64 `json:"id"`
Name string `json:"name"`
CreatedAt time.Time `json:"created_at"`
}
// CreateUserRequest enthält die Felder zum Anlegen eines Nutzers.
type CreateUserRequest struct {
Name string `json:"name"`
}
// Validate prüft den Request.
func (r *CreateUserRequest) Validate() error {
r.Name = strings.TrimSpace(r.Name)
if len(r.Name) == 0 {
return errors.New("Name darf nicht leer sein")
}
if len(r.Name) > 50 {
return errors.New("Name darf maximal 50 Zeichen lang sein")
}
return nil
}