Documentation ¶
Index ¶
- Constants
- Variables
- type Manager
- func (m *Manager) CheckAPIKey(ctx context.Context, apiKeyID, apiKeySecret string) (*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) RegisterPasswordResetCode(ctx context.Context, userEmail, baseURL 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) ResetPassword(ctx context.Context, codeB64, newPassword, 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)
- func (m *Manager) VerifyPasswordResetCode(ctx context.Context, codeB64 string) error
- type ManagerMock
- func (m *ManagerMock) CheckAPIKey(ctx context.Context, apiKeyID, apiKeySecret string) (*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) RegisterPasswordResetCode(ctx context.Context, userEmail, baseURL 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) ResetPassword(ctx context.Context, code, newPassword, 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)
- func (m *ManagerMock) VerifyPasswordResetCode(ctx context.Context, code string) error
Constants ¶
const ( // PasswordMinEntropyBits represents the minimum amount of entropy bits // required for a password. PasswordMinEntropyBits = 50 )
Variables ¶
var ( // ErrInvalidPassword indicates that the password provided is not valid. ErrInvalidPassword = errors.New("invalid password") // ErrInvalidPasswordResetCode indicates that the password reset code // provided is not valid. ErrInvalidPasswordResetCode = errors.New("invalid password reset code") // 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
func (m *Manager) CheckAPIKey(ctx context.Context, apiKeyID, apiKeySecret string) (*hub.CheckAPIKeyOutput, error)
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) RegisterPasswordResetCode ¶ added in v0.16.0
RegisterPasswordResetCode registers a code that allows the user identified by the email provided to reset the password. A link containing the code will be email to the user to initiate the password reset process.
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. When a user is registered using oauth, the email is verified automatically and no email is sent.
func (*Manager) ResetPassword ¶ added in v0.16.0
ResetPassword resets the user password in the database.
func (*Manager) UpdatePassword ¶
UpdatePassword updates the user password in the database.
func (*Manager) UpdateProfile ¶
UpdateProfile updates the user profile in the database.
func (*Manager) VerifyEmail ¶
VerifyEmail verifies a user's email using the email verification code provided.
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, apiKeyID, apiKeySecret string) (*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) RegisterPasswordResetCode ¶ added in v0.16.0
func (m *ManagerMock) RegisterPasswordResetCode(ctx context.Context, userEmail, baseURL string) error
RegisterPasswordResetCode implements the UserManager interface.
func (*ManagerMock) RegisterSession ¶
RegisterSession implements the UserManager interface.
func (*ManagerMock) RegisterUser ¶
RegisterUser implements the UserManager interface.
func (*ManagerMock) ResetPassword ¶ added in v0.16.0
func (m *ManagerMock) ResetPassword(ctx context.Context, code, newPassword, baseURL string) error
ResetPassword 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.
func (*ManagerMock) VerifyPasswordResetCode ¶ added in v0.16.0
func (m *ManagerMock) VerifyPasswordResetCode(ctx context.Context, code string) error
VerifyPasswordResetCode implements the UserManager interface.