pin

package
v0.0.0-...-0b42950 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrValidation  = fmt.Errorf("validation error")
	ErrCreatePin   = fmt.Errorf("pin creation error")
	ErrDBPersist   = fmt.Errorf("persist to database error")
	ErrPinNotFound = fmt.Errorf("pin not found in database")
)

--- list of error and constants

Functions

func DoPasswordsMatch

func DoPasswordsMatch(hashedPassword, currPassword string, salt []byte) bool

Check if two passwords match

func GenerateRandomSalt

func GenerateRandomSalt(saltSize int) []byte

Generate 16 bytes randomly and securely using the Cryptographically secure pseudorandom number generator (CSPRNG) in the crypto.rand package

func HashPassword

func HashPassword(password string, salt []byte) string

Combine password and salt then hash them using the SHA-512 hashing algorithm and then return the hashed password as a base64 encoded string

func RegisterHandlers

func RegisterHandlers(r *routing.RouteGroup, service Service, authHandler routing.Handler, logger log.Logger)

RegisterHandlers sets up the routing of the HTTP handlers.

Types

type Repository

type Repository interface {
	// Get returns the customer's pin information with the specified token string.
	Get(ctx context.Context, customerid string) (entity.Pin, error)
	// Save will store a pin information into data source.
	Save(ctx context.Context, pin entity.Pin) error
	// Update will store an updated pin information into data source.
	Update(ctx context.Context, pin entity.Pin) error
}

Repository encapsulates the logic to access pin from the data source.

func NewRepository

func NewRepository(db *dbcontext.DB, logger log.Logger) Repository

NewRepository creates a new pin repository

type Service

type Service interface {
	Get(ctx context.Context, customer_id string) (entity.Pin, error)
	Validate(ctx context.Context, req entity.Input) (valid bool, err error)
	Create(ctx context.Context, req entity.Input) (err error)
	Change(ctx context.Context, req entity.Input) (err error)
}

Service encapsulates usecase logic for albums.

func NewService

func NewService(repo Repository, logger log.Logger) Service

NewService creates a new payment token service.

Jump to

Keyboard shortcuts

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