Initial commit: Plataforma de Economía
Features: - React 18 + TypeScript frontend with Vite - Go + Gin backend API - PostgreSQL database - JWT authentication with refresh tokens - User management (admin panel) - Docker containerization - Progress tracking system - 4 economic modules structure Fixed: - Login with username or email - User creation without required email - Database nullable timestamps - API response field naming
This commit is contained in:
50
backend/internal/models/user.go
Normal file
50
backend/internal/models/user.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Usuario struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Email string `json:"email"`
|
||||
Username string `json:"username"`
|
||||
PasswordHash string `json:"-"`
|
||||
Nombre string `json:"nombre"`
|
||||
Rol string `json:"rol"` // admin, estudiante
|
||||
CreadoEn time.Time `json:"creado_en"`
|
||||
UltimoLogin *time.Time `json:"ultimo_login"`
|
||||
Activo bool `json:"activo"`
|
||||
}
|
||||
|
||||
type UsuarioCreate struct {
|
||||
Username string `json:"username" binding:"required"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
Nombre string `json:"nombre" binding:"required"`
|
||||
Rol string `json:"rol"`
|
||||
}
|
||||
|
||||
type UsuarioUpdate struct {
|
||||
Email string `json:"email"`
|
||||
Nombre string `json:"nombre"`
|
||||
Activo *bool `json:"activo"`
|
||||
}
|
||||
|
||||
type LoginRequest struct {
|
||||
Email string `json:"email"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
}
|
||||
|
||||
type LoginResponse struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
ExpiresIn int `json:"expires_in"` // seconds
|
||||
User *Usuario `json:"user"`
|
||||
}
|
||||
|
||||
type RefreshRequest struct {
|
||||
RefreshToken string `json:"refresh_token" binding:"required"`
|
||||
}
|
||||
Reference in New Issue
Block a user