28 lines
698 B
Go
28 lines
698 B
Go
// Package users owns the user account entity and its CRUD operations.
|
|
// The auth module depends on this package to look up credentials, but
|
|
// never owns or duplicates the User model itself.
|
|
package users
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const (
|
|
RoleAdmin = "admin"
|
|
RoleCustomer = "customer"
|
|
)
|
|
|
|
type User struct {
|
|
ID uuid.UUID `gorm:"type:uuid;primaryKey"`
|
|
Email string `gorm:"uniqueIndex;not null"`
|
|
PasswordHash string `gorm:"not null"`
|
|
Role string `gorm:"not null;default:admin"`
|
|
IsActive bool `gorm:"not null;default:true"`
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
func (User) TableName() string { return "users" }
|