Documentation ¶
Index ¶
- type BufferNotifier
- type EmailNotifier
- type Event
- type Notifier
- type Payload
- type Stapler
- func (p Stapler) Archive(user *models.User, id int) error
- func (p Stapler) Create(staple models.Staple, user *models.User) error
- func (p Stapler) Delete(user *models.User, id int) (err error)
- func (p Stapler) Get(user *models.User, id int) (*models.Staple, error)
- func (p Stapler) GetNext(user *models.User) (*models.Staple, error)
- func (p Stapler) List(user *models.User) ([]models.Staple, error)
- func (p Stapler) ShowArchive(user *models.User) ([]models.Staple, error)
- type Staplerer
- type UserHandler
- func (u UserHandler) ChangePassword(user models.User, newPassword string) error
- func (u UserHandler) Delete(user models.User) error
- func (u UserHandler) GetMaximumStaples(user models.User) (staples int, err error)
- func (u UserHandler) IsRegistered(user models.User) (ok bool, err error)
- func (u UserHandler) PasswordMatch(user models.User) (ok bool, err error)
- func (u UserHandler) Register(user models.User) error
- func (u UserHandler) ResetPassword(user models.User) error
- func (u UserHandler) SendConfirmCode(user models.User) error
- func (u UserHandler) SetMaximumStaples(user models.User, maxStaples int) error
- func (u UserHandler) VerifyConfirmCode(user models.User) (ok bool, err error)
- type UserHandlerer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferNotifier ¶
type BufferNotifier struct {
// contains filtered or unexported fields
}
BufferNotifier uses a byte buffer for notifications.
func NewBufferNotifier ¶
func NewBufferNotifier() *BufferNotifier
NewBufferNotifier creates a new notifier.
type EmailNotifier ¶
type EmailNotifier struct{}
EmailNotifier is an email based notification entity.
func NewEmailNotifier ¶
func NewEmailNotifier() EmailNotifier
NewEmailNotifier creates a new email notifier.
type Event ¶
type Event string
Event represents an event that can happen which needs the user's attention via prefered notification medium.
var ( // PasswordReset is an event that happens when the user's password is reset. PasswordReset Event = "Password Reset" // GenerateConfirmCode is an event before password reset which sends a confirm code to the user's email address. GenerateConfirmCode Event = "Confirm Code" // Welcome template for new sign-ups. Welcome Event = "Welcome" )
type Stapler ¶
type Stapler struct {
// contains filtered or unexported fields
}
Stapler defines a stapler which stores the staples in Postgres DB.
func NewStapler ¶
func NewStapler(storer storage.StapleStorer) Stapler
NewStapler creates a new Postgres based Stapler which will have a connection to a DB.
func (Stapler) Archive ¶
Archive will archive a staple which isn't removed but rather not shown in the queue. Archived Staples can be retrieved and vewied in any order.
func (Stapler) Create ¶
Create creates a new Staple for the given user. noinspection GoErrorStringFormat
type Staplerer ¶
type Staplerer interface { Create(staple models.Staple, user *models.User) (err error) Delete(user *models.User, id int) (err error) Get(user *models.User, id int) (staple *models.Staple, err error) GetNext(user *models.User) (staple *models.Staple, err error) List(user *models.User) (staples []models.Staple, err error) Archive(user *models.User, id int) (err error) ShowArchive(use *models.User) ([]models.Staple, error) }
Staplerer describes a stapler service which takes care of managing the user's staples.
type UserHandler ¶
type UserHandler struct {
// contains filtered or unexported fields
}
UserHandler defines a storage using user handler.
func NewUserHandler ¶
func NewUserHandler(ctx context.Context, store storage.UserStorer, notifier Notifier) UserHandler
NewUserHandler creates a new user handler.
func (UserHandler) ChangePassword ¶
func (u UserHandler) ChangePassword(user models.User, newPassword string) error
ChangePassword changes the user's password to a new given string.
func (UserHandler) Delete ¶
func (u UserHandler) Delete(user models.User) error
Delete removes a user.
func (UserHandler) GetMaximumStaples ¶
func (u UserHandler) GetMaximumStaples(user models.User) (staples int, err error)
GetMaximumStaples returns the maximum allowed configured staples for a user.
func (UserHandler) IsRegistered ¶
func (u UserHandler) IsRegistered(user models.User) (ok bool, err error)
IsRegistered checks if a user exists in the system.
func (UserHandler) PasswordMatch ¶
func (u UserHandler) PasswordMatch(user models.User) (ok bool, err error)
PasswordMatch checks if a stored password matches that of a given one.
func (UserHandler) Register ¶
func (u UserHandler) Register(user models.User) error
Register registers a user.
func (UserHandler) ResetPassword ¶
func (u UserHandler) ResetPassword(user models.User) error
ResetPassword generates a new password for a user and send it via email. This happens after the confirmation was successfull.
func (UserHandler) SendConfirmCode ¶
func (u UserHandler) SendConfirmCode(user models.User) error
SendConfirmCode sends a confirm code which has to be verified.
func (UserHandler) SetMaximumStaples ¶
func (u UserHandler) SetMaximumStaples(user models.User, maxStaples int) error
SetMaximumStaples sets the user's maximum number of allowed staples.
func (UserHandler) VerifyConfirmCode ¶
func (u UserHandler) VerifyConfirmCode(user models.User) (ok bool, err error)
VerifyConfirmCode will match the confirm code with a stored code for an email address. If the match is successful the code is removed and the password is reset.
type UserHandlerer ¶
type UserHandlerer interface { Register(user models.User) error Delete(user models.User) error ResetPassword(user models.User) error IsRegistered(user models.User) (ok bool, err error) PasswordMatch(user models.User) (ok bool, err error) SendConfirmCode(user models.User) error VerifyConfirmCode(user models.User) (bool, error) SetMaximumStaples(user models.User, maxStaples int) error GetMaximumStaples(user models.User) (int, error) ChangePassword(user models.User, newPassword string) error }
UserHandlerer defines a service which can manage users.