Documentation
¶
Overview ¶
Package account offers capabilities for managing and persisting accounts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateAccountRequest ¶
type CreateAccountRequest struct {
ID string `json:"id" valid:"uuid4"`
Username string `json:"username" valid:"required"`
Password string `json:"password" valid:"required"`
Data string `json:"data" valid:"json"`
}
CreateAccountRequest is used to pass an accounts data to Storage.Create.
type DefaultAccount ¶
type DefaultAccount struct {
ID string `json:"id"`
Username string `json:"username" valid:"required"`
Password string `json:"-"`
Data string `json:"data,omitempty" valid:"json"`
}
func (*DefaultAccount) GetData ¶
func (a *DefaultAccount) GetData() string
func (*DefaultAccount) GetID ¶
func (a *DefaultAccount) GetID() string
func (*DefaultAccount) GetPassword ¶
func (a *DefaultAccount) GetPassword() string
func (*DefaultAccount) GetUsername ¶
func (a *DefaultAccount) GetUsername() string
type Storage ¶
type Storage interface {
// Create creates a new account
Create(r CreateAccountRequest) (Account, error)
// Get fetches an account by its ID.
Get(id string) (Account, error)
// Delete deletes an account by its ID.
Delete(id string) error
// UpdatePassword updates an account's password.
UpdatePassword(id string, r UpdatePasswordRequest) (Account, error)
// UpdateUsername updates an account's username.
UpdateUsername(id string, r UpdateUsernameRequest) (Account, error)
// UpdateData updates an account's extra data (e.g. profile picture)
UpdateData(id string, r UpdateDataRequest) (Account, error)
// Authenticate fetches an account by its username and password
Authenticate(username, password string) (Account, error)
}
Storage manages accounts in a persistent fashion.
type UpdateDataRequest ¶
type UpdateDataRequest struct {
Data string `json:"data" valid:"json,required"`
}
UpdateDataRequest is used to pass an accounts data to Storage.UpdateData.
type UpdatePasswordRequest ¶
type UpdatePasswordRequest struct {
CurrentPassword string `json:"currentPassword" valid:"required"`
NewPassword string `json:"newPassword" valid:"required"`
}
UpdatePasswordRequest is used to pass the request data to Storage.UpdatePassword.
type UpdateUsernameRequest ¶
type UpdateUsernameRequest struct {
Password string `json:"password" valid:"required"`
Username string `json:"username" valid:"required"`
}
UpdateUsernameRequest is used to pass the request data to Storage.UpdateUsername.
Click to show internal directories.
Click to hide internal directories.