hako/internal/model/auth.go
2026-01-12 19:35:18 +01:00

42 lines
900 B
Go

package model
import (
"time"
"github.com/google/uuid"
)
// User represents a user in the domain
type User struct {
ID uuid.UUID
Email string
PasswordHash string
Role string
CreatedAt time.Time
UpdatedAt time.Time
}
// NewUser creates a new user with generated ID and timestamps
// Role defaults to "user" if not specified
func NewUser(email, passwordHash string) *User {
return NewUserWithRole(email, passwordHash, "user")
}
// NewUserWithRole creates a new user with generated ID, timestamps, and specified role
func NewUserWithRole(email, passwordHash, role string) *User {
now := time.Now()
return &User{
ID: uuid.New(),
Email: email,
PasswordHash: passwordHash,
Role: role,
CreatedAt: now,
UpdatedAt: now,
}
}
// Token represents a JWT token
type Token struct {
Token string
ExpiresAt time.Time
}