Documentation ¶
Overview ¶
Package user contains handles the state of users.
Index ¶
- Variables
- type Backend
- type Dao
- func (d Dao) Backend() Backend
- func (d Dao) Create(ctx context.Context, u User) error
- func (d Dao) Delete(ctx context.Context, u User) error
- func (d Dao) Login(ctx context.Context, u User) (*User, error)
- func (d Dao) UpdatePassword(ctx context.Context, u User, newPassword string) error
- func (d Dao) UpdatePointsIncrement(ctx context.Context, usernamePoints map[string]int) error
- type NoDatabaseBackend
- func (b NoDatabaseBackend) Create(ctx context.Context, u User) error
- func (b NoDatabaseBackend) Delete(ctx context.Context, u User) error
- func (b NoDatabaseBackend) Read(ctx context.Context, u User) (*User, error)
- func (b NoDatabaseBackend) UpdatePassword(ctx context.Context, u User) error
- func (b NoDatabaseBackend) UpdatePointsIncrement(ctx context.Context, usernamePoints map[string]int) error
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrIncorrectLogin error = fmt.Errorf("incorrect username/password")
ErrIncorrectLogin should be returned if a login attempt fails because the credentials are invalid.
Functions ¶
This section is empty.
Types ¶
type Backend ¶ added in v1.2.0
type Backend interface { // Create adds the username/password pair. Create(ctx context.Context, u User) error // Get validates the username/password pair and gets the points. Read(ctx context.Context, u User) (*User, error) // UpdatePassword updates the password for user identified by the username. UpdatePassword(ctx context.Context, u User) error // UpdatePointsIncrement increments the points for all of the usernames. UpdatePointsIncrement(ctx context.Context, usernamePoints map[string]int) error // Delete removes the user. Delete(ctx context.Context, u User) error }
Backend contains the operations to manage users
type Dao ¶
type Dao struct {
// contains filtered or unexported fields
}
Dao contains CRUD operations for user-related information.
func (Dao) Login ¶
Login gets ensures the username/password combination is valid and returns all information about the user. The user is returned if the backend is a NoDatabaseBackend.
func (Dao) UpdatePassword ¶
UpdatePassword sets the password of a user.
type NoDatabaseBackend ¶ added in v1.2.0
type NoDatabaseBackend struct{}
func (NoDatabaseBackend) Create ¶ added in v1.2.0
func (b NoDatabaseBackend) Create(ctx context.Context, u User) error
Create returns an error.
func (NoDatabaseBackend) Delete ¶ added in v1.2.0
func (b NoDatabaseBackend) Delete(ctx context.Context, u User) error
Delete returns an error.
func (NoDatabaseBackend) UpdatePassword ¶ added in v1.2.0
func (b NoDatabaseBackend) UpdatePassword(ctx context.Context, u User) error
UpdatePassword returns an error
func (NoDatabaseBackend) UpdatePointsIncrement ¶ added in v1.2.0
func (b NoDatabaseBackend) UpdatePointsIncrement(ctx context.Context, usernamePoints map[string]int) error
UpdatePointsIncrement returns an error.
Click to show internal directories.
Click to hide internal directories.