usersvc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2017 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHashFailed    = svcerror.New(codes.HashFailed, "bcrypt hash failed")
	ErrUserExists    = svcerror.New(codes.UserExists, "user already exists")
	ErrWrongEmail    = svcerror.New(codes.WrongEmail, "wrong email")
	ErrWrongPassword = svcerror.New(codes.WrongPassword, "wrong password")
	ErrNotFound      = svcerror.New(codes.NotFound, "not found")
	ErrDeleteOwner   = svcerror.New(codes.DeleteOwner, "cannot delete user while it is an owner")
)
View Source
var (
	CSRF = csrf.Protect([]byte("aNdRgUkXp2r5u8x/A?D(G+KbPeShVmYq"), csrf.Secure(secure))
	//ErrBadRouting    = errors.New("Inconsistent mapping between route and handler (programmer error).")
	//ErrPersistCookie = errors.New("Failed to add a cookie. Make sure to enable cookies.")
	//ErrInternal      = errors.New("We're having a problem on our end. Hang tight and we'll get it fixed.")
	//ErrNoChallenge   = errors.New("no challenge present")
	//ErrBadRequest    = errors.New("There was an issue parsing the request.")
	//ErrBadToken      = errors.New("Could not exchange token.")
	//ErrNotVerified   = errors.New("The consent challenge could not be verified")
	ErrInternal   = svcerror.New(codes.Nil, "internal server error")
	ErrBadRouting = svcerror.New(codes.BadRouting, "inconsistent mapping between route and handler (programmer error)")
	ErrBadRequest = svcerror.New(codes.BadRequest, "request is malformed or invalid")
)

Functions

func DecodeGetProfileRequest

func DecodeGetProfileRequest(_ context.Context, r *http.Request) (request interface{}, err error)

func DecodeGetUserInfoRequest

func DecodeGetUserInfoRequest(_ context.Context, r *http.Request) (request interface{}, err error)

func MakeDeleteUserEndpoint

func MakeDeleteUserEndpoint(s Service) endpoint.Endpoint

func MakeGetConsent

func MakeGetConsent(client *sdk.Client, logger log.Logger) http.Handler

func MakeGetLogin

func MakeGetLogin() http.Handler

func MakeGetLogout

func MakeGetLogout() http.Handler

func MakeGetProfileEndpoint

func MakeGetProfileEndpoint(s Service) endpoint.Endpoint

func MakeGetRegister

func MakeGetRegister() http.Handler

func MakeGetUserInfoEndpoint

func MakeGetUserInfoEndpoint(s Service) endpoint.Endpoint

func MakeHTTPHandler

func MakeHTTPHandler(s Service, client *sdk.Client, logger log.Logger) http.Handler

MakeHTTPHandler mounts all of the service endpoints into an http.Handler. Useful in a usersvc server.

func MakePostConsent

func MakePostConsent(client *sdk.Client, logger log.Logger) http.Handler

func MakePostLogin

func MakePostLogin(s Service, logger log.Logger) http.Handler

func MakePostRegister

func MakePostRegister(s Service, logger log.Logger) http.Handler

func MakeUpdateUserEndpoint

func MakeUpdateUserEndpoint(s Service) endpoint.Endpoint

Types

type Endpoints

type Endpoints struct {
	GetUserInfoEndpoint endpoint.Endpoint
	GetProfileEndpoint  endpoint.Endpoint
	UpdateUserEndpoint  endpoint.Endpoint
	DeleteUserEndpoint  endpoint.Endpoint
}

func MakeServerEndpoints

func MakeServerEndpoints(s Service) Endpoints

type Service

type Service interface {
	GetProfile(ctx context.Context, userID uuid.UUID) (name string, err error)
	GetUserInfo(ctx context.Context) (user *models.User, err error)
	CreateUser(name, email, password string) error
	SetName(ctx context.Context, name string) error
	SetEmail(ctx context.Context, email string) error
	SetPassword(ctx context.Context, password string) error
	Authenticate(email string, password string) (uuid.UUID, error)
	DeleteUser(ctx context.Context) error
	ResetPassword(ctx context.Context, email string) error
}

func New

func New(db *sql.DB, cs classsvc.Service) Service

Jump to

Keyboard shortcuts

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