user

package
v0.0.0-...-8fab053 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Collection = "users"
)

Variables

View Source
var (
	// ErrNotFound is used when a specific User is requested but does not exist.
	ErrNotFound = errors.New("not found")

	// ErrInvalidID occurs when an ID is not in a valid form.
	ErrInvalidID = errors.New("ID is not in its proper form")

	// ErrAuthenticationFailure occurs when a user attempts to authenticate but
	// anything goes wrong.
	ErrAuthenticationFailure = errors.New("authentication failed")

	// ErrForbidden occurs when a user tries to do something that is forbidden to them according to our access control policies.
	ErrForbidden = errors.New("attempted action is not allowed")
)

Functions

This section is empty.

Types

type Info

type Info struct {
	ID           primitive.ObjectID `bson:"_id"`
	Name         string             `bson:"name,omitempty" json:"name"`
	Slug         string             `bson:"slug,omitempty" json:"slug"`
	Roles        []string           `bson:"roles" json:"roles"`
	Email        string             `bson:"email" json:"email"`
	PasswordHash []byte             `bson:"password_hash" json:"-"`
	Description  string             `bson:"description,omitempty" json:"description"`
	CreatedAt    time.Time          `bson:"created_at,omitempty" json:"created_at"`
}

type NewUser

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

type User

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

func New

func New(log *logrus.Logger, db *mongo.Database) User

New constructs a seller for api access.

func (User) Authenticate

func (u User) Authenticate(ctx context.Context, now time.Time, email, password string) (auth.Claims, error)

func (User) Create

func (u User) Create(ctx context.Context, nu NewUser, now time.Time) (Info, error)

Jump to

Keyboard shortcuts

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