Documentation ¶
Index ¶
- Constants
- func QuerySiteName(siteID string, fullName bool, mentixHost, dataEndpoint string) (string, error)
- type Account
- func (acc *Account) CheckScopeAccess(scope string) bool
- func (acc *Account) Cleanup()
- func (acc *Account) Clone(erasePassword bool) *Account
- func (acc *Account) Configure(other *Account) error
- func (acc *Account) GetSiteID() key.SiteIdentifier
- func (acc *Account) Update(other *Account, setPassword bool, copyData bool) error
- func (acc *Account) UpdatePassword(pwd string) error
- type AccountData
- type AccountSettings
- type Accounts
- type FileStorage
- func (storage *FileStorage) AccountAdded(account *Account)
- func (storage *FileStorage) AccountRemoved(account *Account)
- func (storage *FileStorage) AccountUpdated(account *Account)
- func (storage *FileStorage) ReadAll() (*Accounts, error)
- func (storage *FileStorage) WriteAll(accounts *Accounts) error
- type SiteInformation
- type Storage
Constants ¶
const ( // ScopeDefault is the default account panel scope. ScopeDefault = "" // ScopeGOCDB is used to access the GOCDB. ScopeGOCDB = "gocdb" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Account ¶
type Account struct { Email string `json:"email"` Title string `json:"title"` FirstName string `json:"firstName"` LastName string `json:"lastName"` Site string `json:"site"` Role string `json:"role"` PhoneNumber string `json:"phoneNumber"` Password password.Password `json:"password"` DateCreated time.Time `json:"dateCreated"` DateModified time.Time `json:"dateModified"` Data AccountData `json:"data"` Settings AccountSettings `json:"settings"` }
Account represents a single site account.
func NewAccount ¶
func NewAccount(email string, title, firstName, lastName string, site, role string, phoneNumber string, password string) (*Account, error)
NewAccount creates a new site account.
func (*Account) CheckScopeAccess ¶
CheckScopeAccess checks whether the user can access the specified scope.
func (*Account) Clone ¶
Clone creates a copy of the account; if erasePassword is set to true, the password will be cleared in the cloned object.
func (*Account) GetSiteID ¶ added in v1.12.0
func (acc *Account) GetSiteID() key.SiteIdentifier
GetSiteID returns the site ID (generated from the API key) for the given account.
func (*Account) UpdatePassword ¶
UpdatePassword assigns a new password to the account, hashing it first.
type AccountData ¶
type AccountData struct { APIKey key.APIKey `json:"apiKey"` GOCDBAccess bool `json:"gocdbAccess"` Authorized bool `json:"authorized"` }
AccountData holds additional data for a site account.
type AccountSettings ¶
type AccountSettings struct {
ReceiveAlerts bool `json:"receiveAlerts"`
}
AccountSettings holds additional settings for a site account.
type FileStorage ¶
type FileStorage struct { Storage // contains filtered or unexported fields }
FileStorage implements a filePath-based storage.
func NewFileStorage ¶
func NewFileStorage(conf *config.Configuration, log *zerolog.Logger) (*FileStorage, error)
NewFileStorage creates a new filePath storage.
func (*FileStorage) AccountAdded ¶
func (storage *FileStorage) AccountAdded(account *Account)
AccountAdded is called when an account has been added.
func (*FileStorage) AccountRemoved ¶
func (storage *FileStorage) AccountRemoved(account *Account)
AccountRemoved is called when an account has been removed.
func (*FileStorage) AccountUpdated ¶
func (storage *FileStorage) AccountUpdated(account *Account)
AccountUpdated is called when an account has been updated.
func (*FileStorage) ReadAll ¶ added in v1.12.0
func (storage *FileStorage) ReadAll() (*Accounts, error)
ReadAll reads all stored accounts into the given data object.
func (*FileStorage) WriteAll ¶ added in v1.12.0
func (storage *FileStorage) WriteAll(accounts *Accounts) error
WriteAll writes all stored accounts from the given data object.
type SiteInformation ¶
SiteInformation holds the most basic information about a site.
func QueryAvailableSites ¶
func QueryAvailableSites(mentixHost, dataEndpoint string) ([]SiteInformation, error)
QueryAvailableSites uses Mentix to query a list of all available (registered) sites.
type Storage ¶
type Storage interface { // ReadAll reads all stored accounts into the given data object. ReadAll() (*Accounts, error) // WriteAll writes all stored accounts from the given data object. WriteAll(accounts *Accounts) error // AccountAdded is called when an account has been added. AccountAdded(account *Account) // AccountUpdated is called when an account has been updated. AccountUpdated(account *Account) // AccountRemoved is called when an account has been removed. AccountRemoved(account *Account) }
Storage defines the interface for accounts storages.