53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package domain
|
|
|
|
import "time"
|
|
|
|
// UserID is a typed user identifier with prefix "usr_".
|
|
type UserID string
|
|
|
|
// UserStatus represents the account state.
|
|
type UserStatus string
|
|
|
|
const (
|
|
UserStatusActive UserStatus = "active"
|
|
UserStatusSuspended UserStatus = "suspended"
|
|
UserStatusDeactivated UserStatus = "deactivated"
|
|
)
|
|
|
|
// User is the full domain model for a registered user.
|
|
// This is the database-backed identity, separate from auth.User which is the
|
|
// lightweight JWT-derived identity carried in request context.
|
|
type User struct {
|
|
ID UserID
|
|
Email string
|
|
EmailVerified bool
|
|
Name string
|
|
AvatarURL string
|
|
Status UserStatus
|
|
Roles []string
|
|
LastLoginAt *time.Time
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
// Validation constants for user fields.
|
|
const (
|
|
MaxNameLen = 100
|
|
MaxEmailLen = 254 // RFC 5321
|
|
)
|
|
|
|
// NewUser creates a new user with default values.
|
|
func NewUser(id UserID, email, name string) *User {
|
|
now := time.Now()
|
|
return &User{
|
|
ID: id,
|
|
Email: email,
|
|
EmailVerified: false,
|
|
Name: name,
|
|
Status: UserStatusActive,
|
|
Roles: []string{"user"},
|
|
CreatedAt: now,
|
|
UpdatedAt: now,
|
|
}
|
|
}
|