Documentation ¶
Overview ¶
Package users handles user authentication, user items etc.
Index ¶
- Variables
- type Service
- func (s *Service) AuthUser(authToken string, tokenSalt string) (*User, error)
- func (s *Service) Authenticate(email, password, tokenSalt string) (*User, error)
- func (s *Service) Create(user User) (*User, error)
- func (s *Service) CreateItem(user *User, data map[string]string) (*items.Item, error)
- func (s *Service) Delete(user *User) (*User, error)
- func (s *Service) DeleteItem(user *User, itemID string) (*items.Item, error)
- func (s *Service) Item(user *User, itemID string) (*items.Item, error)
- func (s *Service) Items(user *User, start, limit int) ([]items.Item, error)
- func (s *Service) Read(email string) (*User, error)
- func (s *Service) Update(user *User, data map[string]string) (*User, error)
- func (s *Service) UpdateItem(user *User, itemID string, data map[string]string) (*items.Item, error)
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrEmail is returned when the email address provided is wrong ErrEmail = errors.New("Invalid or no email provided") // ErrCreate is returned if there's an error creating new user ErrCreate = errors.New("Sorry, an error occurred while creating new user") // ErrInvPwd is returned if the password is invalid ErrInvPwd = errors.New("Sorry, invalid or no password provided") // ErrUsrNotExists is returned when trying to login with an non-registered email ErrUsrNotExists = errors.New("Sorry, there's no user registered with that email") // ErrUsrExists is returned when trying to create a user with the same email ErrUsrExists = errors.New("Sorry, user with that email already exists") // ErrNotAuthenticated is returned when the user is not authenticated and trying to perform // an action which requires authentication ErrNotAuthenticated = errors.New("Sorry, the user is not authenticated") ErrUnauthorized = errors.New("Sorry, you're not authorized to perform this action") // ErrMalformedCipher is returned when the cipher text is invalid and cannot be used ErrMalformedCipher = errors.New("malformed ciphertext") )
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service holds all the dependencies of items
func NewService ¶
NewService returns a new instance of Service with all the dependencies initialized
func (*Service) Authenticate ¶
Authenticate authenticates a user and returns the user instance along with the auth token
func (*Service) CreateItem ¶
CreateItem adds a new item owned by the user
func (*Service) DeleteItem ¶
DeleteItem removes an item owned by the user
type User ¶
type User struct { ID string `json:"id,omitempty" bson:"id,omitempty"` Name string `json:"name,omitempty" bson:"name,omitempty"` Email string `json:"email,omitempty" bson:"email,omitempty"` Password []byte `json:"-" bson:"password,omitempty"` Salt string `json:"-" bson:"salt,omitempty"` AuthToken string `bson:"-" json:"authToken,omitempty"` EncryptedPassword []byte `bson:"-" json:"-"` CreatedAt *time.Time `json:"createdAt,omitempty" bson:"createdAt,omitempty"` ModifiedAt *time.Time `json:"modifiedAt,omitempty" bson:"modifiedAt,omitempty"` }
User struct holds all the user details
Click to show internal directories.
Click to hide internal directories.