package models import ( "errors" "time" "github.com/google/uuid" "gorm.io/gorm" ) var ErrEmptyPassword = errors.New("empty password") type User struct { ID uuid.UUID `gorm:"primarykey" json:"id"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` Username string `gorm:"unique" json:"username"` Email string `gorm:"unique" json:"email"` Password string `json:"-"` Experience int Games []*GameCursor Role UserRole } func (u *User) HasRole(role UserRole) bool { return u.Role >= role } type UserRole int const ( RoleUser UserRole = iota RoleCreator RoleAdmin )