users

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package users is a generated GoMock package.

Package users provides core business logic providing API over credentials store and PM API.

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
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 ClientManager

type ClientManager interface {
	GetClient(userID string) pmapi.Client
	GetAnonymousClient() pmapi.Client
	AllowProxy()
	DisallowProxy()
	GetAuthUpdateChannel() chan pmapi.ClientAuth
	CheckConnection() error
}

type Configer

type Configer interface {
	GetAppVersion() string
	GetAPIConfig() *pmapi.ClientConfig
}

type CredentialsStorer

type CredentialsStorer interface {
	List() (userIDs []string, err error)
	Add(userID, userName, apiToken, mailboxPassword string, emails []string) (*credentials.Credentials, error)
	Get(userID string) (*credentials.Credentials, error)
	SwitchAddressMode(userID string) error
	UpdateEmails(userID string, emails []string) error
	UpdatePassword(userID, password string) error
	UpdateToken(userID, apiToken string) error
	Logout(userID string) error
	Delete(userID string) error
}

type Locator added in v1.6.3

type Locator interface {
	Clear() error
}

type MockListener

type MockListener struct {
	// contains filtered or unexported fields
}

MockListener is a mock of Listener interface

func NewMockListener

func NewMockListener(ctrl *gomock.Controller) *MockListener

NewMockListener creates a new mock instance

func (*MockListener) Add

func (m *MockListener) Add(eventName string, channel chan<- string)

Add mocks base method

func (*MockListener) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockListener) Emit

func (m *MockListener) Emit(eventName, data string)

Emit mocks base method

func (*MockListener) Remove

func (m *MockListener) Remove(eventName string, channel chan<- string)

Remove mocks base method

func (*MockListener) RetryEmit

func (m *MockListener) RetryEmit(eventName string)

RetryEmit mocks base method

func (*MockListener) SetBuffer

func (m *MockListener) SetBuffer(eventName string)

SetBuffer mocks base method

func (*MockListener) SetLimit

func (m *MockListener) SetLimit(eventName string, limit time.Duration)

SetLimit mocks base method

type MockListenerMockRecorder

type MockListenerMockRecorder struct {
	// contains filtered or unexported fields
}

MockListenerMockRecorder is the mock recorder for MockListener

func (*MockListenerMockRecorder) Add

func (mr *MockListenerMockRecorder) Add(eventName, channel interface{}) *gomock.Call

Add indicates an expected call of Add

func (*MockListenerMockRecorder) Emit

func (mr *MockListenerMockRecorder) Emit(eventName, data interface{}) *gomock.Call

Emit indicates an expected call of Emit

func (*MockListenerMockRecorder) Remove

func (mr *MockListenerMockRecorder) Remove(eventName, channel interface{}) *gomock.Call

Remove indicates an expected call of Remove

func (*MockListenerMockRecorder) RetryEmit

func (mr *MockListenerMockRecorder) RetryEmit(eventName interface{}) *gomock.Call

RetryEmit indicates an expected call of RetryEmit

func (*MockListenerMockRecorder) SetBuffer

func (mr *MockListenerMockRecorder) SetBuffer(eventName interface{}) *gomock.Call

SetBuffer indicates an expected call of SetBuffer

func (*MockListenerMockRecorder) SetLimit

func (mr *MockListenerMockRecorder) SetLimit(eventName, limit interface{}) *gomock.Call

SetLimit indicates an expected call of SetLimit

type PanicHandler

type PanicHandler interface {
	HandlePanic()
}

type StoreMaker

type StoreMaker interface {
	New(user store.BridgeUser) (*store.Store, error)
	Remove(userID string) error
}

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

func (u *User) CheckBridgeLogin(password string) error

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

func (u *User) CloseConnection(address string)

CloseConnection emits closeConnection event on `address` which should close all active connection.

func (*User) GetAddressID

func (u *User) GetAddressID(address string) (id string, err error)

GetAddressID returns the API ID of the given address.

func (*User) GetAddresses

func (u *User) GetAddresses() []string

GetAddresses returns list of all addresses.

func (*User) GetBridgePassword

func (u *User) GetBridgePassword() string

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

func (u *User) GetPrimaryAddress() string

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) GetStore

func (u *User) GetStore() *store.Store

func (*User) GetStoreAddresses

func (u *User) GetStoreAddresses() []string

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) GetTemporaryPMAPIClient

func (u *User) GetTemporaryPMAPIClient() pmapi.Client

GetTemporaryPMAPIClient returns an authorised PMAPI client. Do not use! It's only for backward compatibility of old SMTP and IMAP implementations. After proper refactor of SMTP and IMAP remove this method.

func (*User) ID

func (u *User) ID() string

ID returns the user's userID.

func (*User) IsAuthorized

func (u *User) IsAuthorized() bool

IsAuthorized returns whether the user has received an Auth from the API yet.

func (*User) IsCombinedAddressMode

func (u *User) IsCombinedAddressMode() bool

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

func (u *User) IsConnected() bool

IsConnected returns whether user is logged in.

func (*User) Logout

func (u *User) Logout() (err error)

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

func (u *User) SwitchAddressMode() (err error)

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

func (u *User) UpdateUser() error

UpdateUser updates user details from API and saves to the credentials.

func (*User) Username

func (u *User) Username() string

Username returns the user's username as found in the user's 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 ClientManager,
	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) CheckConnection

func (u *Users) CheckConnection() error

CheckConnection returns whether there is an internet connection. This should use the connection manager when it is eventually implemented.

func (*Users) ClearData

func (u *Users) ClearData() error

ClearData closes all connections (to release db files and so on) and clears all data.

func (*Users) DeleteUser

func (u *Users) DeleteUser(userID string, clearStore bool) error

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(authClient pmapi.Client, auth *pmapi.Auth, mbPassphrase string) (user *User, err error)

FinishLogin finishes the login procedure and adds the user into the credentials store.

func (*Users) GetUser

func (u *Users) GetUser(query string) (*User, error)

GetUser returns a user by `query` which is compared to users' ID, username or any attached e-mail address.

func (*Users) GetUsers

func (u *Users) GetUsers() []*User

GetUsers returns all added users into keychain (even logged out users).

func (*Users) Login

func (u *Users) Login(username, password string) (authClient pmapi.Client, auth *pmapi.Auth, err error)

Login authenticates a user by username/password, returning an authorised client and an auth object. The authorisation scope may not yet be full if the user has 2FA enabled.

func (*Users) SendMetric

func (u *Users) SendMetric(m metrics.Metric) error

SendMetric sends a metric. We don't want to return any errors, only log them.

func (*Users) StopWatchers

func (u *Users) StopWatchers()

StopWatchers stops all goroutines.

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.

Jump to

Keyboard shortcuts

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