user

package
v0.0.0-...-efc3f8c Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package user provides an example of a core business API. Right now these calls are just wrapping the data/store layer. But at some point you will want auditing or something that isn't specific to the data/store layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Core

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

Core manages the set of API's for user access.

func NewCore

func NewCore(log *zap.SugaredLogger, db *sqlx.DB) Core

NewCore constructs a core for user api access.

func (Core) Authenticate

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

Authenticate finds a user by their email and verifies their password. On success it returns a Claims User representing this user. The claims can be used to generate a token for future authentication.

func (Core) Create

func (c Core) Create(ctx context.Context, nu user.NewUser, now time.Time) (user.User, error)

[PS] this is the wrapper around the data layer with some extra business logic Create inserts a new user into the database.

func (Core) Delete

func (c Core) Delete(ctx context.Context, claims auth.Claims, userID string) error

Delete removes a user from the database.

func (Core) Query

func (c Core) Query(ctx context.Context, pageNumber int, rowsPerPage int) ([]user.User, error)

Query retrieves a list of existing users from the database.

func (Core) QueryByEmail

func (c Core) QueryByEmail(ctx context.Context, claims auth.Claims, email string) (user.User, error)

QueryByEmail gets the specified user from the database by email.

func (Core) QueryByID

func (c Core) QueryByID(ctx context.Context, claims auth.Claims, userID string) (user.User, error)

QueryByID gets the specified user from the database.

func (Core) Update

func (c Core) Update(ctx context.Context, claims auth.Claims, userID string, uu user.UpdateUser, now time.Time) error

Update replaces a user document in the database.

Jump to

Keyboard shortcuts

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