Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrUserNotFound = errors.New("user not found") ErrSaltNotFound = errors.New("salt not found") ErrPasswordUsed = errors.New("password already used") ErrUsernameMissing = errors.New("username missing") ErrUsernameInvalid = errors.New("username invalid") ErrUsernameExists = errors.New("username exists") ErrEmailMissing = errors.New("email missing") ErrEmailInvalid = errors.New("email invalid") ErrEmailExists = errors.New("email exists") ErrEmailChangeEmailNotAvaliable = errors.New("email not available for change") ErrEmailValidateTokenNotFound = errors.New("email validation token not found") ErrEmailValidateTokenInvalid = errors.New("email validation token invalid") ErrEmailValidateTokenExpired = errors.New("email validation token expired") ErrPasswordResetTokenNotFound = errors.New("password reset token not found") ErrPasswordResetTokenExpired = errors.New("password reset token expired") )
Errors that are related to the User Service.
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator interface { // Authenticate validates a password of an existing User. Authenticate(ref, password string) (u *User, err error) }
Authenticator authenticates a User by a reference and password.
type EmailService ¶
type EmailService interface { // RequestEmailChange starts a process of changing an email by // returning a token that must be used in ChangeEmail to authorize // email change. RequestEmailChange(ref, email string, validationDeadline time.Time) (token string, err error) // ChangeEmail changes an email of an existing User only if // provided token is valid. ChangeEmail(ref, token string) (*User, error) // EmailChangeToken retrieves a token to change an email if it exists. EmailChangeToken(ref, email string) (token string, err error) }
EmailService handles e-mail changes.
type ManagementService ¶
type ManagementService interface { // User retrieves a User instance. User(ref string) (*User, error) // UserByID retrieves a User instance only by it's ID. UserByID(id string) (*User, error) // UserByID retrieves a User instance only by it's Email. UserByEmail(email string) (*User, error) // UserByID retrieves a User instance only by it's Username. UserByUsername(username string) (*User, error) // Create user creates a new user interface. CreateUser(o *Options) (*User, error) // UpdateUser changes data of an existing User. UpdateUser(ref string, o *Options) (*User, error) // SetPassword changes a password of an existing User. SetPassword(ref string, password string) error // DeleteUser deletes an existing User. DeleteUser(ref string) (*User, error) // UsersByID retrieves a paginated list of User instances ordered by // ID values. UsersByID(startID string, limit int) (*UsersPage, error) // UsersByEmail retrieves a paginated list of User instances ordered by // Email values. UsersByEmail(startEmail string, limit int) (*UsersPage, error) // UsersByUsername retrieves a paginated list of User instances ordered by // Username values. UsersByUsername(startUsername string, limit int) (*UsersPage, error) }
ManagementService defines most basic functionality for user management.
type Options ¶
type Options struct { Email *string `json:"email,omitempty"` Username *string `json:"username,omitempty"` Name *string `json:"name,omitempty"` Admin *bool `json:"admin,omitempty"` NotificationsDisabled *bool `json:"notifications-disabled,omitempty"` EmailUnvalidated *bool `json:"email-unvalidated,omitempty"` Disabled *bool `json:"disabled,omitempty"` }
Options is a structure with parameters as pointers to set user data. If a parameter is nil, the corresponding User parameter will not be changed.
type PasswordResetService ¶
type PasswordResetService interface { // RequestPasswordReset starts a process of reseting a password by // providing a token that must be used in ResetPassword to authorize // password reset. RequestPasswordReset(ref string) (token string, err error) // ResetPassword changes a password of an existing User only if // provided token is valid. ResetPassword(token, password string) error }
PasswordResetService handles password changes.
type RegisterService ¶
type RegisterService interface { // RegisterUser is a method for adding new users. RegisterUser(o *Options, password string, emailValidationDeadline time.Time) (u *User, emailValidationToken string, err error) }
RegisterService defines user registration interface.
type Service ¶
type Service interface { ManagementService RegisterService PasswordResetService EmailService Authenticator }
Service defines functions that User provider must have. Argument ref in some functions can be a string that is uniquely defined for a user: ID, Username or Email.
type User ¶
type User struct { ID string `json:"id"` Email string `json:"email"` Username string `json:"username,omitempty"` Name string `json:"name,omitempty"` Admin bool `json:"admin,omitempty"` NotificationsDisabled bool `json:"notifications-disabled,omitempty"` EmailUnvalidated bool `json:"email-unvalidated,omitempty"` Disabled bool `json:"disabled,omitempty"` }
User holds user account related data.
type UsersPage ¶
type UsersPage struct { Users []User `json:"users"` // Previous is an reference that // can be used to retrieve previous page. Previous string `json:"previous"` // Previous is an reference that // can be used to retrieve next page. Next string `json:"next"` // Count is a number of User instances in this UserPage. Count int `json:"count"` }
UsersPage is a paginated list of User instances.
Directories ¶
Path | Synopsis |
---|---|
Package boltUser provides a Service that is using local BoltDB database to store User data.
|
Package boltUser provides a Service that is using local BoltDB database to store User data. |
Package httpUser provides a HTTP client to an external user service that can respond to HTTP requests defined here.
|
Package httpUser provides a HTTP client to an external user service that can respond to HTTP requests defined here. |
Package ldapUser provides a Service that uses LDAP for user authentication.
|
Package ldapUser provides a Service that uses LDAP for user authentication. |