Documentation ¶
Overview ¶
Package memory provides an implementation of api.UserService that uses memory as a storage.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService stores all the users in memory and implements auth.UserService interface.
func New ¶
func New() *UserService
New returns a new UserService. It initialises the underlying storage which in this case is map.
func (*UserService) Authenticate ¶
Authenticate authenticates a user by validating that it exists and hash of the provided password matches. On success returns a JWT token. While this method returns different errors for different failures the end user should only see a generic "invalid credentials" message.
func (*UserService) Create ¶
func (s *UserService) Create(u api.UserRegister) error
Create creates a new user. Returns an error if user with the same username or the same email already exist or if passwords do not match.