Documentation ¶
Index ¶
- Constants
- Variables
- type Datastore
- func (d *Datastore) AddIDEConfig(orgID uuid.UUID, config *IDEConfig) error
- func (d *Datastore) ApproveAllOrgUsers(orgID uuid.UUID) error
- func (d *Datastore) CreateInviteSigningKey(id uuid.UUID) (string, error)
- func (d *Datastore) CreateOrg(orgInfo *OrgInfo) (uuid.UUID, error)
- func (d *Datastore) CreateUser(userInfo *UserInfo) (uuid.UUID, error)
- func (d *Datastore) CreateUserAndOrg(orgInfo *OrgInfo, userInfo *UserInfo) (uuid.UUID, uuid.UUID, error)
- func (d *Datastore) DeleteIDEConfig(orgID uuid.UUID, name string) error
- func (d *Datastore) DeleteOrgAndUsers(orgID uuid.UUID) error
- func (d *Datastore) DeleteUser(userID uuid.UUID) error
- func (d *Datastore) GetIDEConfig(orgID uuid.UUID, name string) (*IDEConfig, error)
- func (d *Datastore) GetIDEConfigs(orgID uuid.UUID) ([]*IDEConfig, error)
- func (d *Datastore) GetInviteSigningKey(id uuid.UUID) (string, error)
- func (d *Datastore) GetOrg(id uuid.UUID) (*OrgInfo, error)
- func (d *Datastore) GetOrgByDomain(domainName string) (*OrgInfo, error)
- func (d *Datastore) GetOrgByName(name string) (*OrgInfo, error)
- func (d *Datastore) GetOrgs() ([]*OrgInfo, error)
- func (d *Datastore) GetUser(id uuid.UUID) (*UserInfo, error)
- func (d *Datastore) GetUserAttributes(id uuid.UUID) (*UserAttributes, error)
- func (d *Datastore) GetUserByAuthProviderID(id string) (*UserInfo, error)
- func (d *Datastore) GetUserByEmail(email string) (*UserInfo, error)
- func (d *Datastore) GetUserSettings(id uuid.UUID) (*UserSettings, error)
- func (d *Datastore) GetUsersInOrg(orgID uuid.UUID) ([]*UserInfo, error)
- func (d *Datastore) NumUsersInOrg(orgID uuid.UUID) (int, error)
- func (d *Datastore) SetUserAttributes(attributes *UserAttributes) error
- func (d *Datastore) UpdateOrg(orgInfo *OrgInfo) error
- func (d *Datastore) UpdateUser(userInfo *UserInfo) error
- func (d *Datastore) UpdateUserSettings(settings *UserSettings) error
- type IDEConfig
- type OrgInfo
- type UserAttributes
- type UserInfo
- type UserSettings
Constants ¶
const (
// SaltLength is the length of the salt used when encrypting the invite signing key.
SaltLength = 10
)
Variables ¶
var ( // ErrUserNotFound is used when a user is not found when looking up by a filter condition. ErrUserNotFound = errors.New("user not found") // ErrOrgNotFound is used when the org is not found when looking up by a filter condition. ErrOrgNotFound = errors.New("org not found") // ErrNoInviteKey is used when the org doesn't have a invite key set. ErrNoInviteKey = errors.New("org has no invite signing key") // ErrUserAttributesNotFound is used when no attributes can be found for the given user. ErrUserAttributesNotFound = errors.New("user attributes not found") // ErrUserSettingsNotFound is used when no settings can be found for the given user. ErrUserSettingsNotFound = errors.New("user settings not found") // ErrDuplicateOrgName is used when the given org name is already in use. ErrDuplicateOrgName = errors.New("cannot create org (name already in use)") // ErrDuplicateUser is used when the user creation violates unique constraints for auth_provider_id or email. ErrDuplicateUser = errors.New("cannot create duplicate user") )
Functions ¶
This section is empty.
Types ¶
type Datastore ¶
type Datastore struct {
// contains filtered or unexported fields
}
Datastore is a postgres backed storage for entities.
func NewDatastore ¶
NewDatastore creates a Datastore.
func (*Datastore) AddIDEConfig ¶
AddIDEConfig adds the IDE config to the org.
func (*Datastore) ApproveAllOrgUsers ¶
ApproveAllOrgUsers sets all users is_approved column to true in an org.
func (*Datastore) CreateInviteSigningKey ¶
CreateInviteSigningKey creates an invite signing key for the given orgID.
func (*Datastore) CreateUser ¶
CreateUser creates a new user.
func (*Datastore) CreateUserAndOrg ¶
func (d *Datastore) CreateUserAndOrg(orgInfo *OrgInfo, userInfo *UserInfo) (uuid.UUID, uuid.UUID, error)
CreateUserAndOrg creates a new user and organization as needed for initial user/org creation.
func (*Datastore) DeleteIDEConfig ¶
DeleteIDEConfig deletes the IDE config from the org.
func (*Datastore) DeleteOrgAndUsers ¶
DeleteOrgAndUsers deletes the org and users with a given org ID.
func (*Datastore) DeleteUser ¶
DeleteUser deletes a user, but not the org.
func (*Datastore) GetIDEConfig ¶
GetIDEConfig gets the IDE config for the IDE with the given name.
func (*Datastore) GetIDEConfigs ¶
GetIDEConfigs gets all IDE configs for the org.
func (*Datastore) GetInviteSigningKey ¶
GetInviteSigningKey gets the invite signing key for the given orgID.
func (*Datastore) GetOrgByDomain ¶
GetOrgByDomain gets org information by domain.
func (*Datastore) GetOrgByName ¶
GetOrgByName gets org information by domain.
func (*Datastore) GetUserAttributes ¶
func (d *Datastore) GetUserAttributes(id uuid.UUID) (*UserAttributes, error)
GetUserAttributes fetches the settings for the given user and keys.
func (*Datastore) GetUserByAuthProviderID ¶
GetUserByAuthProviderID gets userinfo by auth provider id.
func (*Datastore) GetUserByEmail ¶
GetUserByEmail gets user info by email.
func (*Datastore) GetUserSettings ¶
func (d *Datastore) GetUserSettings(id uuid.UUID) (*UserSettings, error)
GetUserSettings fetches the settings for the given user.
func (*Datastore) GetUsersInOrg ¶
GetUsersInOrg gets all users in the given org.
func (*Datastore) NumUsersInOrg ¶
NumUsersInOrg gets the count of users in the given org.
func (*Datastore) SetUserAttributes ¶
func (d *Datastore) SetUserAttributes(attributes *UserAttributes) error
SetUserAttributes updates the user attributes for the given user.
func (*Datastore) UpdateUser ¶
UpdateUser updates the user in the database.
func (*Datastore) UpdateUserSettings ¶
func (d *Datastore) UpdateUserSettings(settings *UserSettings) error
UpdateUserSettings updates the user settings for the given user.
type IDEConfig ¶
IDEConfig is an org-level configuration which defines the IDE paths which can be used to navigate to a given symbol.
type OrgInfo ¶
type OrgInfo struct { ID uuid.UUID `db:"id"` OrgName string `db:"org_name"` DomainName *string `db:"domain_name"` EnableApprovals bool `db:"enable_approvals"` }
OrgInfo tracks information about an organization.
func (*OrgInfo) GetDomainName ¶
GetDomainName is a helper to nil check the DomainName column value and convert NULLs into empty strings for ease of use.
type UserAttributes ¶
UserAttributes is a set of attributes for a user.
type UserInfo ¶
type UserInfo struct { ID uuid.UUID `db:"id"` OrgID *uuid.UUID `db:"org_id"` FirstName string `db:"first_name"` LastName string `db:"last_name"` Email string `db:"email"` ProfilePicture *string `db:"profile_picture"` IsApproved bool `db:"is_approved"` IdentityProvider string `db:"identity_provider"` AuthProviderID string `db:"auth_provider_id"` }
UserInfo tracks information about a specific end-user.
type UserSettings ¶
type UserSettings struct { UserID uuid.UUID `db:"user_id"` AnalyticsOptout *bool `db:"analytics_optout"` }
UserSettings is a set of settings for a user.