organization

package
v1.42.3 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAppName   = "Hanzo App"
	DefaultStoreName = "Default"
)

Variables

View Source
var (
	UserNotTopLevel = errors.New("User is not in the top level namespace.")
)

Functions

func Query

Types

type ByName

type ByName []*Organization

func (ByName) Len

func (o ByName) Len() int

func (ByName) Less

func (o ByName) Less(i, j int) bool

func (ByName) Swap

func (o ByName) Swap(i, j int)

type Organization

type Organization struct {
	mixin.Model[Organization]
	mixin.AccessTokens
	wallet.WalletHolder

	Name       string   `json:"name"`
	FullName   string   `json:"fullName"`
	Owners     []string `json:"owners,omitempty" datastore:",noindex"`
	Admins     []string `json:"admins,omitempty" datastore:",noindex"`
	Moderators []string `json:"moderators,omitempty" datastore:",noindex"`
	Enabled    bool     `json:"enabled"`

	BillingEmail     string                  `json:"billingEmail,omitempty"`
	Phone            string                  `json:"phone,omitempty"`
	Address          Address                 `json:"address,omitempty"`
	SocialMedia      socialmedia.SocialMedia `json:"socialMedia,omitEmpty"`
	Websites         []website.Website       `json:"websites,omitEmpty"`
	WalletPassphrase string                  `json:"-"`

	Timezone string `json:"timezone"`

	Country string `json:"country"`
	TaxId   string `json:"taxId"`

	// Used in generating email templates
	LogoUrl string `json:"logoUrl"`

	// Where is the user's dashboard?
	DashboardUrl string `json:"dashboardUrl"`

	// Fee structure for this organization
	Fees pricing.Fees `json:"fees" datastore:",noindex"`

	// Partner fees (private, should be up to partner to disclose)
	Partners []pricing.Partner `json:"-" datastore:",noindex"`

	// Email settings
	Email email.Settings `json:"email" datastore:",noindex"`

	// Default Store
	DefaultStore string `json:"defaultStore"`

	// Default App
	DefaultApp string `json:"defaultApp"`

	// Plan settings
	Plan struct {
		PlanId    string
		StartDate time.Time
	} `json:"-"`

	// Affiliate configuration
	Affiliate integration.Affiliate `json:"-" datastore:",noindex"`

	// Signup options
	SignUpOptions struct {
		// Controls the enabled status of account after creation
		AccountsEnabledByDefault bool `json:"accountsEnabledByDefault"`

		// Allow direct affiliate sign up
		AllowAffiliateSignup bool `json:"allowAffiliateSignup"`

		// Turns off required backend checks
		NoNameRequired     bool `json:"noNameRequired"`
		NoPasswordRequired bool `json:"noPasswordRequired"`

		// Requires password set on create confirmation
		TwoStageEnabled bool `json:"twoStageEnabled"`
		ImmediateLogin  bool `json:"immediateLogin"`

		UsernameRequired bool `json:"usernameRequired"`
	} `json:"signUpOptions" datastore:",noindex"`

	// Whether we use live or test tokens, mostly applicable to stripe
	Live bool `json:"live"`

	// TODO: Remain to PaymentWhitelist for clarity
	// List of comma deliminated email globs that result in charges of 50 cents
	EmailWhitelist string `json:"emailWhitelist" datastore:",noindex"`

	// integration
	Integrations  integration.Integrations `json:"-" datastore:"-"`
	Integrations_ string                   `json:"-" datastore:",noindex"`

	// Analytics config
	Analytics analytics.Analytics `json:"analytics" datastore:",noindex"`

	// Bitcoi settings
	Bitcoin integration.Bitcoin `json:"-"`

	// Ethereum settings
	Ethereum integration.Ethereum `json:"-"`

	// Mailchimp settings
	Mailchimp integration.Mailchimp `json:"-"`

	// Mandrill settings
	Mandrill integration.Mandrill `json:"-"`

	// Mercury bank connection
	Mercury integration.Mercury `json:"-"`

	// Netlify settings
	Netlify integration.Netlify `json:"-"`

	// Paypal connection
	Paypal integration.Paypal `json:"-"`

	// Plaid connection
	Plaid integration.Plaid `json:"-"`

	// ReAmaze settings
	Reamaze integration.Reamaze `json:"-"`

	Recaptcha integration.Recaptcha `json:"-" datastore:",noindex"`

	// Salesforce settings
	Salesforce integration.Salesforce `json:"-"`

	// Shipwire settings
	Shipwire integration.Shipwire `json:"-"`

	// Square connection
	Square integration.Square `json:"-"`

	// Stripe connection
	Stripe integration.Stripe `json:"-"`

	// Wire transfer settings
	Wire integration.WireTransfer `json:"-"`

	// AuthorizeNet connection
	AuthorizeNet integration.AuthorizeNet `json:"-"`

	// Adyen connection
	Adyen integration.Adyen `json:"-"`

	// Braintree connection
	Braintree integration.Braintree `json:"-"`

	// Recurly connection
	Recurly integration.Recurly `json:"-"`

	// LemonSqueezy connection
	LemonSqueezy integration.LemonSqueezy `json:"-"`

	SecurityToken integration.SecurityToken `json:"-"`

	Currency currency.Type `json:"currency"`
}

func New

func (*Organization) AddAdmin

func (o *Organization) AddAdmin(userOrId string)

Add admin to organization

func (*Organization) AddDefaultTokens

func (o *Organization) AddDefaultTokens()

Old JWT / AccessToken AUTH

func (*Organization) AddOwner

func (o *Organization) AddOwner(userOrId string)

Add admin to organization

func (*Organization) AfterCreate

func (o *Organization) AfterCreate() error

func (Organization) AuthorizeNetToken

func (o Organization) AuthorizeNetToken(sandbox bool) integration.AuthorizeNetConnection

func (*Organization) BeforeCreate

func (o *Organization) BeforeCreate() error

Hooks

func (*Organization) Defaults

func (o *Organization) Defaults()

func (Organization) GetDefaultApp

func (o Organization) GetDefaultApp() (*app.App, error)

Return DefaultApp

func (Organization) GetDefaultStore

func (o Organization) GetDefaultStore() (*store.Store, error)

Return DefaultStore

func (*Organization) GetReferenceToken

func (o *Organization) GetReferenceToken(usr *user.User) (*oauthtoken.Token, bool, error)

func (Organization) GetStripeAccessToken

func (o Organization) GetStripeAccessToken(userId string) (string, error)

func (*Organization) Init

func (o *Organization) Init(db *datastore.Datastore)

func (Organization) IsAdmin

func (o Organization) IsAdmin(userOrId interface{}) bool

func (Organization) IsOwner

func (o Organization) IsOwner(userOrId interface{}) bool

func (Organization) IsPlatformOrg

func (o Organization) IsPlatformOrg() bool

IsPlatformOrg returns true if this is the privileged platform organization. Use this to gate admin-only cross-tenant operations.

func (Organization) IsTestEmail

func (o Organization) IsTestEmail(email string) bool

func (*Organization) Load

func (o *Organization) Load(ps []datastore.Property) (err error)

func (Organization) Namespace

func (o Organization) Namespace() string

Namespace returns the datastore namespace for this organization.

SECURITY: The "platform" org uses the global (empty) namespace to enable cross-org admin operations. All handlers that use this MUST verify the caller has platform-admin privileges before allowing writes. All other orgs are strictly scoped to their own namespace.

func (Organization) Namespaced

func (o Organization) Namespaced(ctx context.Context) context.Context

Namespaced returns a context scoped to this organization's namespace. When called with a gin.Context, we always detach from the HTTP request lifecycle and use context.Background() for the database context. This prevents "context canceled" errors when the browser disconnects or the upstream proxy timeout fires before the ClickHouse query completes.

func (Organization) Pricing

func (o Organization) Pricing() (*pricing.Fees, []pricing.Partner)

func (*Organization) ResetReferenceToken

func (o *Organization) ResetReferenceToken(usr *user.User, claims oauthtoken.Claims) (*oauthtoken.Token, error)

New JWT / OAUTH

func (*Organization) RevokeReferenceToken

func (o *Organization) RevokeReferenceToken(usr *user.User) (*oauthtoken.Token, bool, error)

func (*Organization) Save

func (o *Organization) Save() (ps []datastore.Property, err error)

func (Organization) SquareConfig

func (o Organization) SquareConfig(sandbox bool) integration.SquareConnection

func (Organization) StripeToken

func (o Organization) StripeToken() string

func (*Organization) Validator

func (o *Organization) Validator() *val.Validator

type StripeAccessTokenNotFound

type StripeAccessTokenNotFound struct {
	UserId     string
	LiveUserId string
	TestUserId string
}

func (StripeAccessTokenNotFound) Error

Jump to

Keyboard shortcuts

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