Documentation ¶
Overview ¶
Package boltUser provides a Service that is using local BoltDB database to store User data.
Index ¶
- func NewDB(filename string, fileMode os.FileMode, boltOptions *bolt.Options) (db *bolt.DB, err error)
- type Logger
- type Service
- func (s Service) Authenticate(ref, password string) (u *user.User, err error)
- func (s Service) ChangeEmail(ref, token string) (u *user.User, err error)
- func (s Service) CreateUser(o *user.Options) (u *user.User, err error)
- func (s Service) DataDump(ifModifiedSince *time.Time) (dump *dataDump.Dump, err error)
- func (s Service) DeleteUser(ref string) (u *user.User, err error)
- func (s Service) EmailChangeToken(ref, email string) (token string, err error)
- func (s Service) PeriodicCleanup() (err error)
- func (s Service) RegisterUser(o *user.Options, password string, emailValidationDeadline time.Time) (u *user.User, emailValidationToken string, err error)
- func (s Service) RequestEmailChange(ref, email string, validationDeadline time.Time) (token string, err error)
- func (s Service) RequestPasswordReset(ref string) (token string, err error)
- func (s Service) ResetPassword(token, password string) (err error)
- func (s Service) SetPassword(ref string, password string) (err error)
- func (s Service) UpdateUser(ref string, o *user.Options) (u *user.User, err error)
- func (s Service) User(ref string) (u *user.User, err error)
- func (s Service) UserByEmail(email string) (u *user.User, err error)
- func (s Service) UserByID(id string) (u *user.User, err error)
- func (s Service) UserByUsername(username string) (u *user.User, err error)
- func (s Service) UsersByEmail(startEmail string, limit int) (page *user.UsersPage, err error)
- func (s Service) UsersByID(startID string, limit int) (page *user.UsersPage, err error)
- func (s Service) UsersByUsername(startUsername string, limit int) (page *user.UsersPage, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
Authenticate validates a password of an existing User.
func (Service) ChangeEmail ¶
ChangeEmail changes an email of an existing User only if provided token is valid.
func (Service) CreateUser ¶
CreateUser creates a new User in a BoltDB database.
func (Service) DataDump ¶ added in v0.2.1
DataDump implements dataDump.Interface interface to extract database data in a safe and reliable way.
func (Service) DeleteUser ¶
DeleteUser deletes an existing User.
func (Service) EmailChangeToken ¶
EmailChangeToken retrieves a token to change an email if it exists.
func (Service) PeriodicCleanup ¶
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 ¶
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 ¶
ResetPassword changes a password of an existing User only if provided token is valid.
func (Service) SetPassword ¶
SetPassword changes a password of an existing User.
func (Service) UpdateUser ¶
UpdateUser changes data of an existing User.
func (Service) User ¶
User retrieves a User instance by either ID, Email or Username as ref from a BoltDB database.
func (Service) UserByEmail ¶
UserByEmail retrieves a User instance by email from a BoltDB database.
func (Service) UserByUsername ¶
UserByUsername retrieves a User instance by username from a BoltDB database.
func (Service) UsersByEmail ¶
UsersByEmail retrieves a paginated list of User instances ordered by Email values.