Documentation ¶
Overview ¶
Package users provides core business logic providing API over credentials store and PM API.
Index ¶
- Variables
- type CredentialsStorer
- type Locator
- type PanicHandler
- type StoreMaker
- type User
- func (u *User) CheckBridgeLogin(password string) error
- func (u *User) CloseAllConnections()
- func (u *User) CloseConnection(address string)
- func (u *User) GetAddressID(address string) (id string, err error)
- func (u *User) GetAddresses() []string
- func (u *User) GetBridgePassword() string
- func (u *User) GetClient() pmapi.Client
- func (u *User) GetPrimaryAddress() string
- func (u *User) GetStore() *store.Store
- func (u *User) GetStoreAddresses() []string
- func (u *User) ID() string
- func (u *User) IsCombinedAddressMode() bool
- func (u *User) IsConnected() bool
- func (u *User) Logout() error
- func (u *User) SwitchAddressMode() error
- func (u *User) UpdateUser(ctx context.Context) error
- func (u *User) Username() string
- type Users
- func (u *Users) AllowProxy()
- func (u *Users) ClearData() error
- func (u *Users) DeleteUser(userID string, clearStore bool) error
- func (u *Users) DisallowProxy()
- func (u *Users) FinishLogin(client pmapi.Client, auth *pmapi.Auth, password string) (user *User, err error)
- func (u *Users) GetUser(query string) (*User, error)
- func (u *Users) GetUsers() []*User
- func (u *Users) Login(username, password string) (authClient pmapi.Client, auth *pmapi.Auth, err error)
- func (u *Users) SendMetric(m metrics.Metric) error
Constants ¶
This section is empty.
Variables ¶
var ErrLoggedOutUser = errors.New("account is logged out, use the app to login again")
ErrLoggedOutUser is sent to IMAP and SMTP if user exists, password is OK but user is logged out from the app.
var ( // ErrWrongMailboxPassword is returned when login password is OK but not the mailbox one. ErrWrongMailboxPassword = errors.New("wrong mailbox password") )
Functions ¶
This section is empty.
Types ¶
type CredentialsStorer ¶
type CredentialsStorer interface { List() (userIDs []string, err error) Add(userID, userName, uid, ref, mailboxPassword string, emails []string) (*credentials.Credentials, error) Get(userID string) (*credentials.Credentials, error) SwitchAddressMode(userID string) (*credentials.Credentials, error) UpdateEmails(userID string, emails []string) (*credentials.Credentials, error) UpdatePassword(userID, password string) (*credentials.Credentials, error) UpdateToken(userID, uid, ref string) (*credentials.Credentials, error) Logout(userID string) (*credentials.Credentials, error) Delete(userID string) error }
type PanicHandler ¶
type PanicHandler interface {
HandlePanic()
}
type StoreMaker ¶
type User ¶
type User struct {
// contains filtered or unexported fields
}
User is a struct on top of API client and credentials store.
func (*User) CheckBridgeLogin ¶
CheckBridgeLogin checks whether the user is logged in and the bridge IMAP/SMTP password is correct.
func (*User) CloseAllConnections ¶
func (u *User) CloseAllConnections()
CloseAllConnections calls CloseConnection for all users addresses.
func (*User) CloseConnection ¶
CloseConnection emits closeConnection event on `address` which should close all active connection.
func (*User) GetAddressID ¶
GetAddressID returns the API ID of the given address.
func (*User) GetAddresses ¶
GetAddresses returns list of all addresses.
func (*User) GetBridgePassword ¶
GetBridgePassword returns bridge password. This is not a password of the PM account, but generated password for local purposes to not use a PM account in the clients (such as Thunderbird).
func (*User) GetPrimaryAddress ¶
GetPrimaryAddress returns the user's original address (which is not necessarily the same as the primary address, because a primary address might be an alias and be in position one).
func (*User) GetStoreAddresses ¶
GetStoreAddresses returns all addresses used by the store (so in combined mode, that's just the original address, but in split mode, that's all active addresses).
func (*User) IsCombinedAddressMode ¶
IsCombinedAddressMode returns whether user is set in combined or split mode. Combined mode is the default mode and is what users typically need. Split mode is mostly for outlook as it cannot handle sending e-mails from an address other than the primary one.
func (*User) IsConnected ¶
IsConnected returns whether user is logged in.
func (*User) Logout ¶
Logout logs out the user from pmapi, the credentials store, the mail store, and tries to remove as much sensitive data as possible.
func (*User) SwitchAddressMode ¶
SwitchAddressMode changes mode from combined to split and vice versa. The mode to switch to is determined by the state of the user's credentials in the credentials store. See `IsCombinedAddressMode` for more details.
func (*User) UpdateUser ¶
UpdateUser updates user details from API and saves to the credentials.
type Users ¶
type Users struct {
// contains filtered or unexported fields
}
Users is a struct handling users.
func New ¶
func New( locations Locator, panicHandler PanicHandler, eventListener listener.Listener, clientManager pmapi.Manager, credStorer CredentialsStorer, storeFactory StoreMaker, useOnlyActiveAddresses bool, ) *Users
func (*Users) AllowProxy ¶
func (u *Users) AllowProxy()
AllowProxy instructs the app to use DoH to access an API proxy if necessary. It also needs to work before the app is initialised (because we may need to use the proxy at startup).
func (*Users) ClearData ¶
ClearData closes all connections (to release db files and so on) and clears all data.
func (*Users) DeleteUser ¶
DeleteUser deletes user completely; it logs user out from the API, stops any active connection, deletes from credentials store and removes from the Bridge struct.
func (*Users) DisallowProxy ¶
func (u *Users) DisallowProxy()
DisallowProxy instructs the app to not use DoH to access an API proxy if necessary. It also needs to work before the app is initialised (because we may need to use the proxy at startup).
func (*Users) FinishLogin ¶
func (u *Users) FinishLogin(client pmapi.Client, auth *pmapi.Auth, password string) (user *User, err error)
FinishLogin finishes the login procedure and adds the user into the credentials store.
func (*Users) GetUser ¶
GetUser returns a user by `query` which is compared to users' ID, username or any attached e-mail address.
Directories ¶
Path | Synopsis |
---|---|
Package credentials implements our struct stored in keychain.
|
Package credentials implements our struct stored in keychain. |
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |