user

package
v0.0.0-...-c29186b Latest Latest
Warning

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

Go to latest
Published: Jun 24, 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/data 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 APIs 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 Il 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)

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 deletes 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 retrieves a user by email.

func (Core) QueryByID

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

QueryByID retrieves a user by id.

func (Core) Update

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

Update updates a user from the database.

Jump to

Keyboard shortcuts

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