manager

package
v0.0.0-...-f62d8aa Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package manager is responsible for managing users. Handling operations like creation, listing and deletion safely.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorizer

type Authorizer interface {

	// PasswordHash creates safe hashes from
	// passwords, suitable for storage and comparison later
	// using IsPasswordMatch.
	PasswordHash(pass string) (string, error)
}

Authorizer is responsible for authorization and security related operations

type Manager

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

Manager is responsible for managing users, doing operations like creation, listing and deletion safely. It does that by the composition of interfaces providing storage and authorization.

func New

func New(a Authorizer, s UsersStore) *Manager

New creates a new users manager

func (*Manager) CreateUser

func (m *Manager) CreateUser(ctx context.Context, email string, fullname string, password string) (string, error)

Creates a new user, returning its ID in the case of success or a non-nil error in the case of failure. The following errors can be expected to be wrapped in the returned error giving specific conditions:

- If any of the parameters is invalid: users.InvalidUserParamErr - If any the user already exists: users.UserAlreadyExistsErr

All other errors are to be considered internal errors.

type UsersStore

type UsersStore interface {
	// Adds a new user on storage returning its ID in the case of success
	// or a non-nil error in the case of failure.
	// The following errors MUST be returned (possibly wrapped)
	// giving specific conditions:
	//
	// - If the user already exists: users.UserAlreadyExistsErr
	//
	// All other errors are to be considered internal errors.
	AddUser(ctx context.Context, email users.Email, fullname string, hashedPassword string) (string, error)
}

UsersStore is responsible for storing and retrieving user information

Jump to

Keyboard shortcuts

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