user

package
v1.36.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IgnoreFieldMismatch = datastore.IgnoreFieldMismatch
View Source
var (
	UserNotFound = errors.New("User not found.")
)

Functions

func Query

Types

type Document

type Document struct {
	mixin.DocumentSaveLoad `datastore:"-" json:"-"`

	// Special Kind Facet
	Kind string `search:",facet"`

	Id_               string
	Email             string
	EmailPartials     string
	Username          string
	UsernamePartials  string
	FirstName         string
	FirstNamePartials string
	LastName          string
	LastNamePartials  string
	Phone             string

	BillingAddressName        string
	BillingAddressLine1       string
	BillingAddressLine2       string
	BillingAddressCity        string
	BillingAddressStateCode   string
	BillingAddressState       string
	BillingAddressCountryCode string
	BillingAddressCountry     string
	BillingAddressPostalCode  string

	ShippingAddressName        string
	ShippingAddressLine1       string
	ShippingAddressLine2       string
	ShippingAddressCity        string
	ShippingAddressStateCode   string
	ShippingAddressState       string
	ShippingAddressCountryCode string
	ShippingAddressCountry     string
	ShippingAddressPostalCode  string

	CreatedAt float64
	UpdatedAt float64

	StripeBalanceTransactionId string
	StripeCardId               string
	StripeChargeId             string
	StripeCustomerId           string
	StripeLastFour             string

	KYCStatus  string
	KYCFlagged string
	KYCFrozen  string

	KYCWalletAddresses string

	KYCAddressLine1       string
	KYCAddressLine2       string
	KYCAddressCity        string
	KYCAddressStateCode   string
	KYCAddressState       string
	KYCAddressCountryCode string
	KYCAddressCountry     string
	KYCAddressPostalCode  string

	KYCTaxId     string
	KYCPhone     string
	KYCGender    string
	KYCBirthdate string

	Test string
}

func (Document) Id

func (d Document) Id() string

func (*Document) Init

func (d *Document) Init()

type KYCData

type KYCData struct {
	Flagged      bool      `json:"flagged,omitempty"`
	Frozen       bool      `json:"frozen,omitempty"`
	DateApproved time.Time `json:"dateApproved,omitempty"`

	WalletAddresses []string `json:"walletAddresses,omitempty"`
	Address         Address  `json:"address,omitempty"`
	Documents       []string `json:"documents,omitempty" datastore:"-"`
	Documents_      []byte   `json:"-" datastore:",noindex"`

	TaxId     string    `json:"taxId,omitempty"`
	Phone     string    `json:"phone,omitempty"`
	Birthdate time.Time `json:"birthdate,omitempty"`
	Gender    string    `json:"gender,omitempty"`

	EthereumAddress string `json:"ethereumAddress,omitempty"`
	EOSPublicKey    string `json:"eosPublicKey,omitempty"`
}

type User

type User struct {
	mixin.Model[User]
	mixin.Salesforce
	wallet.WalletHolder

	// Crowdstart Id, found in default namespace
	Cid string `json:"-"`

	Username         string   `json:"username,omitempty"`
	FirstName        string   `json:"firstName"`
	LastName         string   `json:"lastName"`
	Company          string   `json:"company,omitempty"`
	Phone            string   `json:"phone,omitempty"`
	BillingAddress   Address  `json:"billingAddress,omitempty"`
	ShippingAddress  Address  `json:"shippingAddress,omitempty"`
	Email            string   `json:"email"`
	PaypalEmail      string   `json:"paypalEmail,omitempty"`
	PasswordHash     []byte   `schema:"-" datastore:",noindex" json:"-"`
	Organizations    []string `json:"-" datastore:",noindex"`
	StoreId          string   `json:"storeId,omitempty"`
	WalletPassphrase string   `json:"-"`

	Facebook struct {
		AccessToken string `facebook:"-"`
		UserId      string `facebook:"id"`
		FirstName   string `facebook:"first_name"`
		LastName    string `facebook:"last_name"`
		MiddleName  string `facebook:"middle_name"`
		Name        string `facebook:"name" datastore:"-"`
		NameFormat  string `facebook:"name_format"` // For Chinese, Japanese, and Korean names. Possibly used in the future.
		Email       string `facebook:"email" datastore:"-"`
		Verified    bool   `facebook:"verified" datastore:"-"`
	} `json:"-"`

	KYC struct {
		KYCData

		Status KYCStatus `json:"status,omitempty"`
		Hash   string    `json:"hash"`
	} `json:"kyc,omitempty"`

	// Account to use for new orders when customer creates new orders
	Accounts accounts.Account `json:"-" datastore:",noindex"`

	Enabled     bool `json:"enabled"` //whether or not the user can login yet
	PreApproved bool `json:"preApproved"`

	Metadata  Map    `json:"metadata,omitempty" datastore:"-"`
	Metadata_ string `json:"-" datastore:",noindex"`

	Referrals      []referral.Referral           `json:"referrals,omitempty" datastore:"-"`
	Referrers      []referrer.Referrer           `json:"referrers,omitempty" datastore:"-"`
	Orders         []order.Order                 `json:"orders,omitempty" datastore:"-"`
	PendingFees    []fee.Fee                     `json:"pendingFees,omitempty" datastore:"-"`
	PaymentMethods []paymentmethod.PaymentMethod `json:"paymentMethods,omitempty" datastore:"-"`
	Affiliate      affiliate.Affiliate           `json:"affiliate,omitempty" datastore:"-"`

	Transactions map[currency.Type]*util.TransactionData `json:"transactions" datastore:"-"`

	TokenTransactions []*tokentransaction.Transaction `json:"tokenTransactions" datastore:"-"`

	ReferrerId string `json:"referrerId,omitempty"`

	// Series of events that have occured relevant to this order
	History []Event `json:"-,omitempty" datastore:",noindex"`

	IsOwner bool `json:"owner,omitempty" datastore:"-"`

	IsAffiliate bool `json:"isAffiliate,omitempty"`

	AffiliateId string `json:"affiliateId,omitempty"`

	FormId string `json:"formId,omitempty"`

	// For Halcyon
	Commission commission.Commission `json:"commission"`

	Test bool `json:"test"`
}

func Fake

func Fake(db *datastore.Datastore) *User

func New

func New(db *datastore.Datastore) *User

func (*User) AddOrganization

func (u *User) AddOrganization(orgId string)

Save organization to organization slice.

func (*User) AfterCreate

func (u *User) AfterCreate() error

func (*User) AfterDelete

func (u *User) AfterDelete() error

func (*User) AfterUpdate

func (u *User) AfterUpdate(prev *User) error

func (*User) BeforeCreate

func (u *User) BeforeCreate() error

Hooks

func (*User) BeforeUpdate

func (u *User) BeforeUpdate(prev *User) error

func (User) Buyer

func (u User) Buyer() Buyer

func (*User) CalculateBalances

func (u *User) CalculateBalances(test bool) error

func (User) ComparePassword

func (u User) ComparePassword(pass string) bool

func (User) Document

func (u User) Document() mixin.Document

func (*User) GetByEmail

func (u *User) GetByEmail(email string) error

Populates current entity from datastore by Email.

func (*User) GetByUsername

func (u *User) GetByUsername(un string) error

Populates current entity from datastore by Email.

func (User) HasPassword

func (u User) HasPassword() bool

func (*User) InOrganization

func (u *User) InOrganization(orgId string) bool

Check if user is part of an organization

func (*User) Load

func (u *User) Load(ps []datastore.Property) (err error)

func (*User) LoadAffiliateAndPendingFees

func (u *User) LoadAffiliateAndPendingFees() error

func (*User) LoadOrders

func (u *User) LoadOrders() error

func (*User) LoadPaymentMethods

func (u *User) LoadPaymentMethods() error

func (*User) LoadReferrals

func (u *User) LoadReferrals() error

func (*User) LoadTokenTransactions

func (u *User) LoadTokenTransactions() error

func (User) Name

func (u User) Name() string

func (*User) Save

func (u *User) Save() (ps []datastore.Property, err error)

func (*User) SetPassword

func (u *User) SetPassword(newPassword string) error

func (*User) Total

func (u *User) Total() currency.Cents

Total implements referrer.Referrent. Users have no monetary total by themselves.

func (*User) Validator

func (u *User) Validator() *val.Validator

Directories

Path Synopsis
Package user provides the User model using the new db.DB interface.
Package user provides the User model using the new db.DB interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL