users

package
v0.0.0-...-1388524 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

users contains database storage actions for user accounts.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidLogin = errors.New("incorrect login details")

ErrInvalidLogin is returned when the given login details were incorrect.

View Source
var ErrUserExists = errors.New("the username is in use")

ErrUserExists is returned when the given username already exists.

Functions

func Authenticate

func Authenticate(ctx context.Context, username, password string) (*models.Account, error)

Authenticate returns a user matching the given login details, if one exists.

func CreateUser

func CreateUser(ctx context.Context, account *models.Account) error

CreateUser persists a new user account in the database.

Types

type AccountList

type AccountList []*models.Account

An AccountList is a slice of user accounts.

func ListUsers

func ListUsers(ctx context.Context, args ListArgs, filter ListFilter) (AccountList, error)

ListUsers returns a list of user accounts.

func (AccountList) Single

func (accs AccountList) Single() *models.Account

Single returns a single account from an account list. If the list contains zero or multiple accounts, it panics.

type ListArgs

type ListArgs struct {
}

A ListArgs controls the behaviour of ListUsers.

type ListFilter

type ListFilter struct {
	// Filter by a list of account IDs.
	AccountID []int32
	// Filter by a username.
	Username string
}

A ListFilter controls the filtering behaviour of ListUsers. At most a single filter variable may be set.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL