boltUser

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2017 License: BSD-3-Clause Imports: 19 Imported by: 1

Documentation

Overview

Package boltUser provides a Service that is using local BoltDB database to store User data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDB

func NewDB(filename string, fileMode os.FileMode, boltOptions *bolt.Options) (db *bolt.DB, err error)

NewDB opens a new BoltDB database.

Types

type Logger added in v0.4.1

type Logger interface {
	Info(a ...interface{})
	Infof(format string, a ...interface{})
	Errorf(format string, a ...interface{})
}

Logger defines interface for logging messages with various severity levels.

type Service

type Service struct {
	DB *bolt.DB

	// PasswordNoReuseMonths is a number of months for which one password
	// can not be reused. If the value is 0 (default), reuse check is not
	// performed.
	PasswordNoReuseMonths int

	// If UsernameRequired is true, user.UsernameMissing will be returned
	// on CreateUser or UpdateUser if Username if empty string.
	UsernameRequired bool

	Logger Logger
}

Service implements gopherpit.com/gopherpit/services/user.Service interface.

func (Service) Authenticate

func (s Service) Authenticate(ref, password string) (u *user.User, err error)

Authenticate validates a password of an existing User.

func (Service) ChangeEmail

func (s Service) ChangeEmail(ref, token string) (u *user.User, err error)

ChangeEmail changes an email of an existing User only if provided token is valid.

func (Service) CreateUser

func (s Service) CreateUser(o *user.Options) (u *user.User, err error)

CreateUser creates a new User in a BoltDB database.

func (Service) DataDump added in v0.2.1

func (s Service) DataDump(ifModifiedSince *time.Time) (dump *dataDump.Dump, err error)

DataDump implements dataDump.Interface interface to extract database data in a safe and reliable way.

func (Service) DeleteUser

func (s Service) DeleteUser(ref string) (u *user.User, err error)

DeleteUser deletes an existing User.

func (Service) EmailChangeToken

func (s Service) EmailChangeToken(ref, email string) (token string, err error)

EmailChangeToken retrieves a token to change an email if it exists.

func (Service) PeriodicCleanup

func (s Service) PeriodicCleanup() (err error)

PeriodicCleanup deletes expired password resets and email validations periodically.

func (Service) RegisterUser

func (s Service) RegisterUser(o *user.Options, password string, emailValidationDeadline time.Time) (u *user.User, emailValidationToken string, err error)

RegisterUser combines CreateUser SetPassword and RequestEmailChange into a single transaction to provide more convenient method for adding new users.

func (Service) RequestEmailChange

func (s Service) RequestEmailChange(ref, email string, validationDeadline time.Time) (token string, err error)

RequestEmailChange starts a process of changing an email by returning a token that must be used in ChangeEmail to authorize email change.

func (Service) RequestPasswordReset

func (s Service) RequestPasswordReset(ref string) (token string, err error)

RequestPasswordReset starts a process of reseting a password by providing a token that must be used in ResetPassword to authorize password reset.

func (Service) ResetPassword

func (s Service) ResetPassword(token, password string) (err error)

ResetPassword changes a password of an existing User only if provided token is valid.

func (Service) SetPassword

func (s Service) SetPassword(ref string, password string) (err error)

SetPassword changes a password of an existing User.

func (Service) UpdateUser

func (s Service) UpdateUser(ref string, o *user.Options) (u *user.User, err error)

UpdateUser changes data of an existing User.

func (Service) User

func (s Service) User(ref string) (u *user.User, err error)

User retrieves a User instance by either ID, Email or Username as ref from a BoltDB database.

func (Service) UserByEmail

func (s Service) UserByEmail(email string) (u *user.User, err error)

UserByEmail retrieves a User instance by email from a BoltDB database.

func (Service) UserByID

func (s Service) UserByID(id string) (u *user.User, err error)

UserByID retrieves a User instance by ID from a BoltDB database.

func (Service) UserByUsername

func (s Service) UserByUsername(username string) (u *user.User, err error)

UserByUsername retrieves a User instance by username from a BoltDB database.

func (Service) UsersByEmail

func (s Service) UsersByEmail(startEmail string, limit int) (page *user.UsersPage, err error)

UsersByEmail retrieves a paginated list of User instances ordered by Email values.

func (Service) UsersByID

func (s Service) UsersByID(startID string, limit int) (page *user.UsersPage, err error)

UsersByID retrieves a paginated list of User instances ordered by ID values.

func (Service) UsersByUsername

func (s Service) UsersByUsername(startUsername string, limit int) (page *user.UsersPage, err error)

UsersByUsername retrieves a paginated list of User instances ordered by Username values.

Jump to

Keyboard shortcuts

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