user

package
v0.0.0-...-1a2a7be Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2017 License: GPL-3.0 Imports: 9 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknown                   = errors.New("user unknown error")
	ErrUserNotFound              = errors.New("user not found")
	ErrInvalidUsernameOrPassword = errors.New("invalid username or password")
	ErrAccessTokenNotFound       = errors.New("access token not found")
	ErrAgentTokenNotFound        = errors.New("agent token not found")
	ErrBadTokenFormat            = errors.New("bad format token")
)

Functions

This section is empty.

Types

type AccessToken

type AccessToken struct {
	Token    string
	ExpireAt time.Time
}

func NewAccessToken

func NewAccessToken() *AccessToken

func ParseAccessTokenFromString

func ParseAccessTokenFromString(s string) (*AccessToken, error)

type AgentToken

type AgentToken struct {
	Name  string
	Token string
}

func NewAgentToken

func NewAgentToken(name string) *AgentToken

func ParseAgentTokenFromString

func ParseAgentTokenFromString(s string) (*AgentToken, error)

func (*AgentToken) String

func (t *AgentToken) String() string

type Email

type Email string

func (Email) String

func (e Email) String() string

type EncryptedPassword

type EncryptedPassword string

func NewEncryptedPassword

func NewEncryptedPassword(password string) EncryptedPassword

func NewEncryptedPasswordWithSalt

func NewEncryptedPasswordWithSalt(password, salt string) EncryptedPassword

func (EncryptedPassword) Salt

func (ep EncryptedPassword) Salt() string

func (EncryptedPassword) String

func (ep EncryptedPassword) String() string

func (EncryptedPassword) Validate

func (ep EncryptedPassword) Validate(password string) bool

type Repository

type Repository interface {
	CreateUser(*User) (*User, error)
	DeleteUserByID(id UserID) error
	GetUserByID(id UserID) (*User, error)
	CreateAccessToken(UserID, *AccessToken) error
	DeleteAccessTokens(UserID, []*AccessToken) error
	LookupUserByUsername(username string) (*User, error)
	LookupUserByAccessToken(*AccessToken) (*User, error)
	CreateAgentToken(UserID, *AgentToken) error
	DeleteAgentTokens(UserID, []*AgentToken) error
	LookupUserByAgentToken(*AgentToken) (*User, error)
	LookupAgentTokenByName(UserID, string) (*AgentToken, error)
}

type User

type User struct {
	ID       UserID
	Username string
	Password EncryptedPassword
	Email    Email

	AccessTokens []*AccessToken
	AgentTokens  []*AgentToken
}

func NewUser

func NewUser(username, password, email string) *User

func (*User) LookupAccessTokenByString

func (user *User) LookupAccessTokenByString(s string) (*AccessToken, bool)

func (*User) LookupAgentTokenByString

func (user *User) LookupAgentTokenByString(s string) (*AgentToken, bool)

func (*User) ValidatePassword

func (user *User) ValidatePassword(password string) bool

type UserID

type UserID string

func (UserID) String

func (id UserID) String() string

Jump to

Keyboard shortcuts

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