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 ¶
- type Core
- func (c Core) Authenticate(ctx context.Context, now time.Time, email, password string) (auth.Claims, error)
- func (c Core) Create(ctx context.Context, nu user.NewUser, now time.Time) (user.User, error)
- func (c Core) Delete(ctx context.Context, claims auth.Claims, userID string) error
- func (c Core) Query(ctx context.Context, pageNumber int, rowsPerPage int) ([]user.User, error)
- func (c Core) QueryByEmail(ctx context.Context, claims auth.Claims, email string) (user.User, error)
- func (c Core) QueryByID(ctx context.Context, claims auth.Claims, userID string) (user.User, error)
- func (c Core) Update(ctx context.Context, claims auth.Claims, userID string, uu user.UpdateUser, ...) error
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 ¶
[PS] this is the wrapper around the data layer with some extra business logic Create inserts a new user into 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.