Documentation ¶
Index ¶
- Variables
- func DoPasswordsMatch(hashedPassword, currPassword string, salt []byte) bool
- func GenerateRandomSalt(saltSize int) []byte
- func HashPassword(password string, salt []byte) string
- func RegisterHandlers(r *routing.RouteGroup, service Service, authHandler routing.Handler, ...)
- type Repository
- type Service
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 ¶
Check if two passwords match
func GenerateRandomSalt ¶
Generate 16 bytes randomly and securely using the Cryptographically secure pseudorandom number generator (CSPRNG) in the crypto.rand package
func HashPassword ¶
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.
Click to show internal directories.
Click to hide internal directories.