Documentation ¶
Overview ¶
Package user provides a core business API.
Index ¶
- Variables
- type Core
- func (c *Core) Authenticate(email string, password string) (User, error)
- func (c *Core) Create(nu NewUser) (User, error)
- func (c *Core) CreateTx(nuTx NewUserTx) (User, error)
- func (c *Core) Delete(usr User) error
- func (c *Core) Query(pageNumber int, rowsPerPage int) ([]User, error)
- func (c *Core) QueryByEmail(email string) (User, error)
- func (c *Core) QueryByID(id uuid.UUID) (User, error)
- func (c *Core) QueryByTopicID(topicID uuid.UUID) ([]User, error)
- func (c *Core) Update(usr User, uu UpdateUser) (User, error)
- type NewUser
- type NewUserTx
- type Role
- type Storer
- type UpdateUser
- type User
Constants ¶
This section is empty.
Variables ¶
var ( RoleAdmin = Role{"ADMIN"} RoleUser = Role{"USER"} )
Set of possible roles for a user.
var ( ErrNotFound = errors.New("user not found") ErrUniqueEmail = errors.New("email is not unique") ErrAuthenticationFailure = errors.New("authentication failed") ErrAuthorizationFailure = errors.New("authorization failed") )
Set of error variables for CRUD operations.
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 (*Core) Authenticate ¶
func (*Core) QueryByEmail ¶
QueryByEmail finds the user by a specified user email.
type Role ¶
type Role struct {
// contains filtered or unexported fields
}
Role represents a role in the system.
func MustParseRole ¶
MustParseRole parses the string value and returns a role if one exists. If an error occurs the function panics.
func (Role) MarshalText ¶
MarshalText implement the marshal interface for JSON conversions.
func (*Role) UnmarshalText ¶
UnmarshalText implement the unmarshal interface for JSON conversions.
type Storer ¶
type Storer interface { WithinTran(fn func(s Storer) error) error Create(usr User) error Update(usr User) error Delete(usr User) error Query(pageNumber int, rowsPerPage int) ([]User, error) QueryByID(id uuid.UUID) (User, error) QueryByEmail(email string) (User, error) QueryByTopicID(topicID uuid.UUID) ([]User, error) }
Storer interface declares the behavior this package needs to perists and retrieve data.
type UpdateUser ¶
UpdateUser contains information needed to update a user.