uservalue

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package interestvalue provides struct values and associated operations for user handling including persistence in postgres

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NewUser

type NewUser struct {
	Name            string   `json:"name" validate:"required"`
	Email           string   `json:"email" validate:"required"`
	Roles           []string `json:"roles" validate:"required"`
	Password        string   `json:"password" validate:"required"`
	PasswordConfirm string   `json:"password_confirm" validate:"eqfield=Password"`
}

NewUser contains information needed to create a new User.

type PasswordGenerator

type PasswordGenerator struct{}

func (PasswordGenerator) Hash

func (pf PasswordGenerator) Hash(password []byte) ([]byte, error)

type PasswordGeneratorInterface

type PasswordGeneratorInterface interface {
	Hash(password []byte) ([]byte, error)
}

type User

type User struct {
	Uuid         string         `db:"uuid" json:"uuid"`
	Name         string         `db:"name" json:"name"`
	Email        string         `db:"email" json:"email"`
	Roles        pq.StringArray `db:"roles" json:"roles"`
	PasswordHash []byte         `db:"password_hash" json:"-"`
	DateCreated  time.Time      `db:"date_created" json:"date_created"`
	DateUpdated  time.Time      `db:"date_updated" json:"date_updated"`
}

User represents someone with access to our system.

func AddUser

func AddUser(ctx context.Context, db *sqlx.DB, n NewUser, now time.Time, pg PasswordGeneratorInterface) (*User, error)

func FindByEmail

func FindByEmail(ctx context.Context, db *sqlx.DB, email string) (User, error)

Jump to

Keyboard shortcuts

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