Documentation
¶
Overview ¶
Package userbus provides business access to user domain.
Index ¶
- Constants
- Variables
- func ActionUpdatedData(uu UpdateUser, userID uuid.UUID) delegate.Data
- type ActionUpdatedParms
- type Business
- func (b *Business) Authenticate(ctx context.Context, email mail.Address, password string) (User, error)
- func (b *Business) Count(ctx context.Context, filter QueryFilter) (int, error)
- func (b *Business) Create(ctx context.Context, nu NewUser) (User, error)
- func (b *Business) Delete(ctx context.Context, usr User) error
- func (b *Business) NewWithTx(tx sqldb.CommitRollbacker) (*Business, error)
- func (b *Business) Query(ctx context.Context, filter QueryFilter, orderBy order.By, page page.Page) ([]User, error)
- func (b *Business) QueryByEmail(ctx context.Context, email mail.Address) (User, error)
- func (b *Business) QueryByID(ctx context.Context, userID uuid.UUID) (User, error)
- func (b *Business) Update(ctx context.Context, usr User, uu UpdateUser) (User, error)
- type NewUser
- type QueryFilter
- type RegisterUser
- type Storer
- type UpdateUser
- type UpdateUserPassword
- type User
Constants ¶
const ( OrderByID = "user_id" OrderByName = "name" OrderByEmail = "email" OrderByRoles = "roles" OrderByEnabled = "enabled" )
Set of fields that the results can be ordered by.
const (
ActionUpdated = "updated"
)
Set of delegate actions.
const DomainName = "user"
DomainName represents the name of this domain.
Variables ¶
var ( ErrNotFound = errors.New("user not found") ErrUniqueEmail = errors.New("email is not unique") ErrAuthenticationFailure = errors.New("authentication failed") )
Set of error variables for CRUD operations.
DefaultOrderBy represents the default way we sort.
Functions ¶
func ActionUpdatedData ¶
func ActionUpdatedData(uu UpdateUser, userID uuid.UUID) delegate.Data
ActionUpdatedData constructs the data for the updated action.
Types ¶
type ActionUpdatedParms ¶
type ActionUpdatedParms struct {
UserID uuid.UUID
UpdateUser
}
ActionUpdatedParms represents the parameters for the updated action.
func (*ActionUpdatedParms) Marshal ¶
func (au *ActionUpdatedParms) Marshal() ([]byte, error)
Marshal returns the event parameters encoded as JSON.
func (*ActionUpdatedParms) String ¶
func (au *ActionUpdatedParms) String() string
String returns a string representation of the action parameters.
type Business ¶
type Business struct {
// contains filtered or unexported fields
}
Business manages the set of APIs for user access.
func NewBusiness ¶
NewBusiness constructs a user business API for use.
func (*Business) Authenticate ¶
func (b *Business) Authenticate(ctx context.Context, email mail.Address, password string) (User, 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 (*Business) NewWithTx ¶
func (b *Business) NewWithTx(tx sqldb.CommitRollbacker) (*Business, error)
NewWithTx constructs a new business value that will use the specified transaction in any store related calls.
func (*Business) Query ¶
func (b *Business) Query(ctx context.Context, filter QueryFilter, orderBy order.By, page page.Page) ([]User, error)
Query retrieves a list of existing users.
func (*Business) QueryByEmail ¶
QueryByEmail finds the user by a specified user email.
type NewUser ¶
type NewUser struct {
Name name.Name
Email mail.Address
Roles []role.Role
Department name.Null
Password string
}
NewUser contains information needed to create a new user. New users are created by admins. Users will use Register to update the password and create a UUK payload.
type QueryFilter ¶
type QueryFilter struct {
ID *uuid.UUID
Name *name.Name
Email *mail.Address
StartCreatedDate *time.Time
EndCreatedDate *time.Time
}
QueryFilter holds the available fields a query can be filtered on. We are using pointer semantics because the With API mutates the value.
type RegisterUser ¶
RegisterUser contains information needed to register a user with a password and UUK. Token is the users register token provided by an admin.
type Storer ¶
type Storer interface {
NewWithTx(tx sqldb.CommitRollbacker) (Storer, error)
Create(ctx context.Context, usr User) error
Update(ctx context.Context, usr User) error
Delete(ctx context.Context, usr User) error
Query(ctx context.Context, filter QueryFilter, orderBy order.By, page page.Page) ([]User, error)
Count(ctx context.Context, filter QueryFilter) (int, error)
QueryByID(ctx context.Context, userID uuid.UUID) (User, error)
QueryByEmail(ctx context.Context, email mail.Address) (User, error)
}
Storer interface declares the behavior this package needs to persist and retrieve data.
type UpdateUser ¶
type UpdateUser struct {
Name *name.Name
Email *mail.Address
Roles []role.Role
Department *name.Null
Password *string
Enabled *bool
}
UpdateUser contains information needed to update a user.
type UpdateUserPassword ¶
type UpdateUserPassword struct {
Password *string
}
UpdateUserPassword contains information needed to update user password.
Directories
¶
| Path | Synopsis |
|---|---|
|
stores
|
|
|
usercache
Package usercache contains user related CRUD functionality with caching.
|
Package usercache contains user related CRUD functionality with caching. |
|
userdb
Package userdb contains user related CRUD functionality.
|
Package userdb contains user related CRUD functionality. |