Documentation
¶
Index ¶
- Constants
- Variables
- func Query(db *datastore.Datastore) datastore.Query
- type ByName
- type Organization
- func (o *Organization) AddAdmin(userOrId string)
- func (o *Organization) AddDefaultTokens()
- func (o *Organization) AddOwner(userOrId string)
- func (o *Organization) AfterCreate() error
- func (o Organization) AuthorizeNetToken(sandbox bool) integration.AuthorizeNetConnection
- func (o *Organization) BeforeCreate() error
- func (o *Organization) Defaults()
- func (o Organization) GetDefaultApp() (*app.App, error)
- func (o Organization) GetDefaultStore() (*store.Store, error)
- func (o *Organization) GetReferenceToken(usr *user.User) (*oauthtoken.Token, bool, error)
- func (o Organization) GetStripeAccessToken(userId string) (string, error)
- func (o *Organization) Init(db *datastore.Datastore)
- func (o Organization) IsAdmin(userOrId interface{}) bool
- func (o Organization) IsOwner(userOrId interface{}) bool
- func (o Organization) IsPlatformOrg() bool
- func (o Organization) IsTestEmail(email string) bool
- func (o *Organization) Load(ps []datastore.Property) (err error)
- func (o Organization) Namespace() string
- func (o Organization) Namespaced(ctx context.Context) context.Context
- func (o Organization) Pricing() (*pricing.Fees, []pricing.Partner)
- func (o *Organization) ResetReferenceToken(usr *user.User, claims oauthtoken.Claims) (*oauthtoken.Token, error)
- func (o *Organization) RevokeReferenceToken(usr *user.User) (*oauthtoken.Token, bool, error)
- func (o *Organization) Save() (ps []datastore.Property, err error)
- func (o Organization) SquareConfig(sandbox bool) integration.SquareConnection
- func (o Organization) StripeToken() string
- func (o *Organization) Validator() *val.Validator
- type StripeAccessTokenNotFound
Constants ¶
const ( DefaultAppName = "Hanzo App" DefaultStoreName = "Default" )
Variables ¶
var (
UserNotTopLevel = errors.New("User is not in the top level namespace.")
)
Functions ¶
Types ¶
type ByName ¶
type ByName []*Organization
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 New(db *datastore.Datastore) *Organization
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) 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) 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) 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) 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 ¶
func (StripeAccessTokenNotFound) Error ¶
func (e StripeAccessTokenNotFound) Error() string