Documentation ¶
Index ¶
- Variables
- type Manager
- func (m *Manager) CheckAPIKey(ctx context.Context, key []byte) (*hub.CheckAPIKeyOutput, error)
- func (m *Manager) CheckAvailability(ctx context.Context, resourceKind, value string) (bool, error)
- func (m *Manager) CheckCredentials(ctx context.Context, email, password string) (*hub.CheckCredentialsOutput, error)
- func (m *Manager) CheckSession(ctx context.Context, sessionID []byte, duration time.Duration) (*hub.CheckSessionOutput, error)
- func (m *Manager) DeleteSession(ctx context.Context, sessionID []byte) error
- func (m *Manager) GetProfile(ctx context.Context) (*hub.User, error)
- func (m *Manager) GetProfileJSON(ctx context.Context) ([]byte, error)
- func (m *Manager) GetUserID(ctx context.Context, email string) (string, error)
- func (m *Manager) RegisterSession(ctx context.Context, session *hub.Session) ([]byte, error)
- func (m *Manager) RegisterUser(ctx context.Context, user *hub.User, baseURL string) error
- func (m *Manager) UpdatePassword(ctx context.Context, old, new string) error
- func (m *Manager) UpdateProfile(ctx context.Context, user *hub.User) error
- func (m *Manager) VerifyEmail(ctx context.Context, code string) (bool, error)
- type ManagerMock
- func (m *ManagerMock) CheckAPIKey(ctx context.Context, key []byte) (*hub.CheckAPIKeyOutput, error)
- func (m *ManagerMock) CheckAvailability(ctx context.Context, resourceKind, value string) (bool, error)
- func (m *ManagerMock) CheckCredentials(ctx context.Context, email, password string) (*hub.CheckCredentialsOutput, error)
- func (m *ManagerMock) CheckSession(ctx context.Context, sessionID []byte, duration time.Duration) (*hub.CheckSessionOutput, error)
- func (m *ManagerMock) DeleteSession(ctx context.Context, sessionID []byte) error
- func (m *ManagerMock) GetProfile(ctx context.Context) (*hub.User, error)
- func (m *ManagerMock) GetProfileJSON(ctx context.Context) ([]byte, error)
- func (m *ManagerMock) GetUserID(ctx context.Context, email string) (string, error)
- func (m *ManagerMock) RegisterSession(ctx context.Context, session *hub.Session) ([]byte, error)
- func (m *ManagerMock) RegisterUser(ctx context.Context, user *hub.User, baseURL string) error
- func (m *ManagerMock) UpdatePassword(ctx context.Context, old, new string) error
- func (m *ManagerMock) UpdateProfile(ctx context.Context, user *hub.User) error
- func (m *ManagerMock) VerifyEmail(ctx context.Context, code string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidPassword indicates that the password provided is not valid. ErrInvalidPassword = errors.New("invalid password") // ErrNotFound indicates that the user does not exist. ErrNotFound = errors.New("user not found") )
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager provides an API to manage users.
func NewManager ¶
func NewManager(db hub.DB, es hub.EmailSender) *Manager
NewManager creates a new Manager instance.
func (*Manager) CheckAPIKey ¶ added in v0.2.0
CheckAPIKey checks if the api key provided is valid.
func (*Manager) CheckAvailability ¶
CheckAvailability checks the availability of a given value for the provided resource kind.
func (*Manager) CheckCredentials ¶
func (m *Manager) CheckCredentials( ctx context.Context, email, password string, ) (*hub.CheckCredentialsOutput, error)
CheckCredentials checks if the credentials provided are valid.
func (*Manager) CheckSession ¶
func (m *Manager) CheckSession( ctx context.Context, sessionID []byte, duration time.Duration, ) (*hub.CheckSessionOutput, error)
CheckSession checks if the user session provided is valid.
func (*Manager) DeleteSession ¶
DeleteSession deletes a user session from the database.
func (*Manager) GetProfile ¶ added in v0.6.0
GetProfile returns the profile of the user doing the request.
func (*Manager) GetProfileJSON ¶
GetProfileJSON returns the profile of the user doing the request as a json object.
func (*Manager) RegisterSession ¶
RegisterSession registers a user session in the database.
func (*Manager) RegisterUser ¶
RegisterUser registers the user provided in the database. When the user is registered a verification email will be sent to the email address provided. The base url provided will be used to build the url the user will need to click to complete the verification.
func (*Manager) UpdatePassword ¶
UpdatePassword updates the user password in the database.
func (*Manager) UpdateProfile ¶
UpdateProfile updates the user profile in the database.
type ManagerMock ¶
ManagerMock is a mock implementation of the UserManager interface.
func (*ManagerMock) CheckAPIKey ¶ added in v0.2.0
func (m *ManagerMock) CheckAPIKey(ctx context.Context, key []byte) (*hub.CheckAPIKeyOutput, error)
CheckAPIKey implements the UserManager interface.
func (*ManagerMock) CheckAvailability ¶
func (m *ManagerMock) CheckAvailability(ctx context.Context, resourceKind, value string) (bool, error)
CheckAvailability implements the UserManager interface.
func (*ManagerMock) CheckCredentials ¶
func (m *ManagerMock) CheckCredentials( ctx context.Context, email, password string, ) (*hub.CheckCredentialsOutput, error)
CheckCredentials implements the UserManager interface.
func (*ManagerMock) CheckSession ¶
func (m *ManagerMock) CheckSession( ctx context.Context, sessionID []byte, duration time.Duration, ) (*hub.CheckSessionOutput, error)
CheckSession implements the UserManager interface.
func (*ManagerMock) DeleteSession ¶
func (m *ManagerMock) DeleteSession(ctx context.Context, sessionID []byte) error
DeleteSession implements the UserManager interface.
func (*ManagerMock) GetProfile ¶ added in v0.6.0
GetProfile implements the UserManager interface.
func (*ManagerMock) GetProfileJSON ¶
func (m *ManagerMock) GetProfileJSON(ctx context.Context) ([]byte, error)
GetProfileJSON implements the UserManager interface.
func (*ManagerMock) RegisterSession ¶
RegisterSession implements the UserManager interface.
func (*ManagerMock) RegisterUser ¶
RegisterUser implements the UserManager interface.
func (*ManagerMock) UpdatePassword ¶
func (m *ManagerMock) UpdatePassword(ctx context.Context, old, new string) error
UpdatePassword implements the UserManager interface.
func (*ManagerMock) UpdateProfile ¶
UpdateProfile implements the UserManager interface.
func (*ManagerMock) VerifyEmail ¶
VerifyEmail implements the UserManager interface.