user

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

func (m *Manager) CheckAPIKey(ctx context.Context, key []byte) (*hub.CheckAPIKeyOutput, error)

CheckAPIKey checks if the api key provided is valid.

func (*Manager) CheckAvailability

func (m *Manager) CheckAvailability(ctx context.Context, resourceKind, value string) (bool, error)

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

func (m *Manager) DeleteSession(ctx context.Context, sessionID []byte) error

DeleteSession deletes a user session from the database.

func (*Manager) GetProfile added in v0.6.0

func (m *Manager) GetProfile(ctx context.Context) (*hub.User, error)

GetProfile returns the profile of the user doing the request.

func (*Manager) GetProfileJSON

func (m *Manager) GetProfileJSON(ctx context.Context) ([]byte, error)

GetProfileJSON returns the profile of the user doing the request as a json object.

func (*Manager) GetUserID

func (m *Manager) GetUserID(ctx context.Context, email string) (string, error)

GetUserID returns the id of the user with the email provided.

func (*Manager) RegisterSession

func (m *Manager) RegisterSession(ctx context.Context, session *hub.Session) ([]byte, error)

RegisterSession registers a user session in the database.

func (*Manager) RegisterUser

func (m *Manager) RegisterUser(ctx context.Context, user *hub.User, baseURL string) error

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

func (m *Manager) UpdatePassword(ctx context.Context, old, new string) error

UpdatePassword updates the user password in the database.

func (*Manager) UpdateProfile

func (m *Manager) UpdateProfile(ctx context.Context, user *hub.User) error

UpdateProfile updates the user profile in the database.

func (*Manager) VerifyEmail

func (m *Manager) VerifyEmail(ctx context.Context, code string) (bool, error)

VerifyEmail verifies a user's email using the email verification code provided.

type ManagerMock

type ManagerMock struct {
	mock.Mock
}

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

func (m *ManagerMock) GetProfile(ctx context.Context) (*hub.User, error)

GetProfile implements the UserManager interface.

func (*ManagerMock) GetProfileJSON

func (m *ManagerMock) GetProfileJSON(ctx context.Context) ([]byte, error)

GetProfileJSON implements the UserManager interface.

func (*ManagerMock) GetUserID

func (m *ManagerMock) GetUserID(ctx context.Context, email string) (string, error)

GetUserID implements the UserManager interface.

func (*ManagerMock) RegisterSession

func (m *ManagerMock) RegisterSession(ctx context.Context, session *hub.Session) ([]byte, error)

RegisterSession implements the UserManager interface.

func (*ManagerMock) RegisterUser

func (m *ManagerMock) RegisterUser(ctx context.Context, user *hub.User, baseURL string) error

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

func (m *ManagerMock) UpdateProfile(ctx context.Context, user *hub.User) error

UpdateProfile implements the UserManager interface.

func (*ManagerMock) VerifyEmail

func (m *ManagerMock) VerifyEmail(ctx context.Context, code string) (bool, error)

VerifyEmail implements the UserManager interface.

Jump to

Keyboard shortcuts

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