Documentation
¶
Overview ¶
Package domain contains the administrator management business rules.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidAdminID = errors.New("invalid admin id") ErrInvalidUsername = errors.New("invalid username") ErrInvalidDisplayName = errors.New("invalid display name") ErrInvalidPasswordHash = errors.New("invalid password hash") ErrAdminNeedsRole = errors.New("admin needs at least one role") ErrInvalidActiveRole = errors.New("active role is not assigned") )
Administrator validation errors.
Functions ¶
This section is empty.
Types ¶
type Admin ¶
type Admin struct {
ID int64
Username string
DisplayName string
Email string
PasswordHash []byte
RoleIDs []int64
ActiveRoleID int64
Active bool
CreatedAt time.Time
UpdatedAt time.Time
}
Admin is a validated back-office user that can sign in and operate management APIs.
func NewAdmin ¶
func NewAdmin(username, displayName, email string, passwordHash []byte, roleIDs []int64, activeRoleID int64) (Admin, error)
NewAdmin validates and creates an admin before it is persisted.
func RestoreAdmin ¶
func RestoreAdmin(id int64, username, displayName, email string, passwordHash []byte, roleIDs []int64, activeRoleID int64, active bool, createdAt, updatedAt time.Time) (Admin, error)
RestoreAdmin rebuilds an admin from a trusted store representation.
func (Admin) ReplacePassword ¶
ReplacePassword changes the admin password hash.
func (Admin) SwitchActiveRole ¶
SwitchActiveRole changes the role that authorization should use for new tokens.
Click to show internal directories.
Click to hide internal directories.