accounts

package
v0.0.0-...-d0e7b85 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hasher

type Hasher interface {
	// Hash generates the hashed string from plain-text.
	Hash(string) (string, error)

	// Compare compares plain-text version to the hashed one. An error should
	// indicate failed comparison.
	Compare(string, string) error
}

Hasher specifies an API for generating hashes of an arbitrary textual content.

func NewHasher

func NewHasher() Hasher

NewHasher instantiates a bcrypt-based hasher implementation.

type Metadata

type Metadata map[string]interface{}

Metadata to be used for storing user arrbitary data

type Service

type Service interface {
	// Register creates new user account.
	Register(u User) (id string, err error)
	// Login verifies provided Email/Password with record in DB
	Login(email, password string) (u User, err error)
	// Retrieves user info for a given user ID.
	Get(id string) (u User, err error)
	// GetByEmail retrives user for a given email.
	GetByEmail(email string) (u User, err error)
	// Update updates user account
	Update(u User) error
}

Service specifies users API

func NewUsersService

func NewUsersService(repo UserRepository, logger logger.Logger) Service

NewUsersService init Service

type User

type User struct {
	ID        string
	Email     string
	Password  []byte
	Metadata  Metadata
	CreatedAt time.Time
	UpadtedAt time.Time
}

User defines user account structures

func (User) Validate

func (u User) Validate() error

Validate Do User object validation

type UserRepository

type UserRepository interface {
	Create(u User) (string, error)
	Get(id string) (User, error)
	GetByEmail(email string) (User, error)
	Update(u User) error
	Delete(id string) error
}

UserRepository specifies users persistent storage API

Directories

Path Synopsis
store

Jump to

Keyboard shortcuts

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