users

package
v0.0.0-...-0c294a2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

CheckPasswordHash verifies that the password arguments matches the given hash

func HashPassword

func HashPassword(password string) (string, error)

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

func (*LoginForm) Validate

func (form *LoginForm) Validate() bool

Validate checks that the fields in the login form are set

type RecoveryForm

type RecoveryForm struct {
	Email  string
	Errors map[string]string
}

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

func (*RegistrationForm) Validate

func (form *RegistrationForm) Validate(blacklistFile string, zxcvbnScore int) bool

Validate checks that the fields in the login form are set

type ResetForm

type ResetForm struct {
	Email        string
	Password     string
	PasswordCopy string
	Errors       map[string]string
	Token        string
}

ResetForm represents a reset form

func (*ResetForm) Validate

func (form *ResetForm) Validate(config *config.Server, zxcvbnScore int, token *ResetToken) bool

Validate checks that the fields in the login form are set

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

Jump to

Keyboard shortcuts

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