Documentation ¶
Overview ¶
Package hoser provides a basic User concept incorporating a simple role/permissions capability; a UserService interface to manage users and a concrete implementation backed by BoltHold, a wrapper around the capable BoltDB.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Permissions ¶
Permissions is a map[string]bool representing the permissions or roles a user may have. p["is_admin"] = true
func (Permissions) Grant ¶
func (p Permissions) Grant(permission string)
Grant adds the permission to the user
func (Permissions) IsGranted ¶
func (p Permissions) IsGranted(permission string) bool
IsGranted returns true if the user has the permission
func (Permissions) Ungrant ¶
func (p Permissions) Ungrant(permission string)
Ungrant removes the permission from the user
type User ¶
type User struct { ID uint64 `json:"id" boltholdKey:"ID"` // Primary key FirstName string `json:"first_name" validate:"required"` LastName string `json:"last_name" validate:"required"` Email string `json:"email" validate:"required,email" boltholdIndex:"Email"` Password string `json:"-" validate:"required"` // Hashed password Salt string `json:"-"` Permissions Permissions `json:"-"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
User is a representation of an application user Email is used as the primary lookup key Create new user instances using the NewUser() constructor.
Directories ¶
Path | Synopsis |
---|---|
Package bolthold provides a BoltHold-backed implementation of the hoser.UserService interface.
|
Package bolthold provides a BoltHold-backed implementation of the hoser.UserService interface. |
Package http provides a client for a UserService suitable for incorporating within web applications.
|
Package http provides a client for a UserService suitable for incorporating within web applications. |
Click to show internal directories.
Click to hide internal directories.