Documentation ¶
Index ¶
- func CheckPasswordHash(password, hash string) bool
- func HashPassword(password string) (string, error)
- type LoginForm
- type RecoveryForm
- type RegistrationForm
- type ResetForm
- type ResetToken
- type User
- type UserService
- func (userService *UserService) Login(w http.ResponseWriter, r *http.Request) (form *LoginForm, err error)
- func (userService *UserService) Logout(w http.ResponseWriter, r *http.Request) error
- func (userService *UserService) PasswordRecovery(w http.ResponseWriter, r *http.Request) (form *RecoveryForm, err error)
- func (userService *UserService) PasswordReset(w http.ResponseWriter, r *http.Request) (form *ResetForm, err error)
- func (userService *UserService) Register(w http.ResponseWriter, r *http.Request) (form *RegistrationForm, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPasswordHash ¶
CheckPasswordHash verifies that the password arguments matches the given hash
func HashPassword ¶
HashPassword hashes a password with bcrypt
Types ¶
type LoginForm ¶
type LoginForm struct { Email string Password string Pasted string NoJS string Errors map[string]string }
LoginForm represents a login form
type RecoveryForm ¶
RecoveryForm is a recovery form
func (*RecoveryForm) Validate ¶
func (form *RecoveryForm) Validate() bool
Validate checks that the fields in the login form are set
type RegistrationForm ¶
type RegistrationForm struct { Email string Password string PasswordCopy string Errors map[string]string }
RegistrationForm represents a login form
type ResetForm ¶
type ResetForm struct { Email string Password string PasswordCopy string Errors map[string]string Token string }
ResetForm represents a reset form
type ResetToken ¶
type ResetToken struct { Token string `json:"token"` CreatedAt time.Time `json:"createdAt"` TTL time.Duration `json:"ttl"` }
ResetToken represents a password reset token
type User ¶
type User struct { ID int `json:"id"` Email string `json:"email"` PasswordHash string `json:"password"` LoginAttempts int `json:"loginAttempts"` ResetToken *ResetToken `json:"resetToken"` }
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService represents the user service
func NewUserService ¶
func NewUserService(db *bolt.DB, tipsyConfig *config.Server) (userService *UserService)
NewUserService returns a new UserService instance
func (*UserService) Login ¶
func (userService *UserService) Login(w http.ResponseWriter, r *http.Request) (form *LoginForm, err error)
Login allows a user to login to their account
func (*UserService) Logout ¶
func (userService *UserService) Logout(w http.ResponseWriter, r *http.Request) error
Logout logs a user out
func (*UserService) PasswordRecovery ¶
func (userService *UserService) PasswordRecovery(w http.ResponseWriter, r *http.Request) (form *RecoveryForm, err error)
PasswordRecovery sends the user an email containing a password reset link
func (*UserService) PasswordReset ¶
func (userService *UserService) PasswordReset(w http.ResponseWriter, r *http.Request) (form *ResetForm, err error)
PasswordReset validates the token then updates the user's password
func (*UserService) Register ¶
func (userService *UserService) Register(w http.ResponseWriter, r *http.Request) (form *RegistrationForm, err error)
Register allows a user to register a new account