user

package
v0.0.0-...-3544c3d Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound          = status.Errorf(codes.NotFound, "User not found")
	ErrUserAlreadyExists = status.Errorf(codes.AlreadyExists, "User already exists")
	ErrInvalidPassword   = status.Errorf(codes.InvalidArgument, "Invalid password")
	ErrInvalidEmail      = status.Errorf(codes.InvalidArgument, "Invalid e-mail")
)

Functions

This section is empty.

Types

type DatabaseOperations

type DatabaseOperations struct {
	DB *gorm.DB
	// contains filtered or unexported fields
}

func (*DatabaseOperations) Create

func (dbu *DatabaseOperations) Create(name, email, pass string, admin bool) error

func (*DatabaseOperations) Delete

func (dbu *DatabaseOperations) Delete(email string) error

func (*DatabaseOperations) GetUser

func (dbu *DatabaseOperations) GetUser(email string) (*database.User, error)

func (*DatabaseOperations) Login

func (dbu *DatabaseOperations) Login(email, password string, exp time.Duration) (string, error)

func (*DatabaseOperations) SetPassword

func (dbu *DatabaseOperations) SetPassword(user *database.User, newPassword, userTarget string) error

type FakeOperations

type FakeOperations struct {
	Storage map[string]*database.User
	// contains filtered or unexported fields
}

func (*FakeOperations) Create

func (f *FakeOperations) Create(name, email, pass string, admin bool) error

func (*FakeOperations) Delete

func (f *FakeOperations) Delete(email string) error

func (*FakeOperations) GetUser

func (f *FakeOperations) GetUser(email string) (*database.User, error)

func (*FakeOperations) Login

func (f *FakeOperations) Login(email, password string, exp time.Duration) (string, error)

func (*FakeOperations) SetPassword

func (f *FakeOperations) SetPassword(user *database.User, newPassword, targetUser string) error

type Operations

type Operations interface {
	Login(email, password string, exp time.Duration) (string, error)
	GetUser(email string) (*database.User, error)
	SetPassword(user *database.User, newPassword, userTarget string) error
	Delete(email string) error
	Create(name, email, pass string, admin bool) error
}

func NewDatabaseOperations

func NewDatabaseOperations(db *gorm.DB, a auth.Auth) Operations

func NewFakeOperations

func NewFakeOperations() Operations

type Service

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

func NewService

func NewService(ops Operations) *Service

func (*Service) Create

func (s *Service) Create(ctx context.Context, request *userpb.CreateRequest) (*userpb.Empty, error)

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, request *userpb.DeleteRequest) (*userpb.Empty, error)

func (*Service) Login

func (s *Service) Login(ctx context.Context, request *userpb.LoginRequest) (*userpb.LoginResponse, error)

func (*Service) RegisterService

func (s *Service) RegisterService(grpcServer *grpc.Server)

func (*Service) SetPassword

func (s *Service) SetPassword(ctx context.Context, request *userpb.SetPasswordRequest) (*userpb.Empty, error)

Jump to

Keyboard shortcuts

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