passwordrec

package
v0.0.2-rc-ci Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExpiredRecoveryToken = xerror.BadInputError{Err: fmt.Errorf("expired recovery token")}
View Source
var ErrInvalidRecoveryToken = xerror.BadInputError{Err: fmt.Errorf("invalid recovery token")}

Functions

func NewMemoryStore

NewMemoryStore returns a new in memory store.

func Router

func Router(service *Service) func(chi.Router)

Router returns a new passwordrec router.

Types

type Config

type Config struct {
	RecoveryURL string
	Subject     string
}

Config is used to configure the recover email.

type FindFilters

type FindFilters struct {
	ID          *string
	UserID      *string
	Email       *string
	Token       *string
	RequestedAt *time.Time
}

FindFilters defines the possible filters for the find method.

type Mailer

type Mailer interface {
	Send(email, subject, body string) error
}

type NewPasswordRecovery

type NewPasswordRecovery struct {
	UserID      string    `json:"user_id"`
	Email       string    `json:"email"`
	Token       string    `json:"token"`
	RequestedAt time.Time `json:"requested_at"`
}

NewPasswordRecovery is the model used to create new password recoveries.

type PasswordRecovery

type PasswordRecovery struct {
	ID          string    `json:"id" db:"id"`
	UserID      string    `json:"user_id" db:"user_id"`
	Email       string    `json:"email" db:"email"`
	Token       string    `json:"token" db:"token"`
	RequestedAt time.Time `json:"requested_at" db:"requested_at"`
}

PasswordRecovery is the password recovery model.

func PasswordRecoveryFromNewPasswordRecovery

func PasswordRecoveryFromNewPasswordRecovery(newPasswordRecvoery *NewPasswordRecovery, id string) *PasswordRecovery

InvitationFromNewInvitation converts a NewInvitation to an Invitation with a given id.

func (PasswordRecovery) Identifier

func (p PasswordRecovery) Identifier() string

type RecoveryRequest

type RecoveryRequest struct {
	Email string `json:"email"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(mailService Mailer, userService user.Storer, engine *template.Engine, store Storer, baseURL string) *Service

NewService returns a new recovery service.

func (*Service) RequestRecovery

func (s *Service) RequestRecovery(ctx context.Context, email string) error

func (*Service) SetPassword

func (s *Service) SetPassword(ctx context.Context, token string, password string) error

type SetPasswordRequest

type SetPasswordRequest struct {
	Token    string `json:"token"`
	Password string `json:"password"`
}

type SqlStore

type SqlStore struct {
	// contains filtered or unexported fields
}

func NewSqlStore

func NewSqlStore(db *sqlx.DB) *SqlStore

NewSqlStore returns a new sql db passwordrec store.

func (*SqlStore) Create

func (s *SqlStore) Create(ctx context.Context, newPasswordRecovery *NewPasswordRecovery) (*PasswordRecovery, error)

func (*SqlStore) Delete

func (s *SqlStore) Delete(ctx context.Context, id string) error

func (*SqlStore) Find

func (*SqlStore) FindByID

func (s *SqlStore) FindByID(ctx context.Context, id string) (*PasswordRecovery, error)

func (*SqlStore) RunMigrations

func (s *SqlStore) RunMigrations(ctx context.Context) error

func (*SqlStore) Update

func (s *SqlStore) Update(ctx context.Context, passwordrec *PasswordRecovery) (*PasswordRecovery, error)

type Storer

Storer defines an interface for accessing the PasswordRecovery model.

Jump to

Keyboard shortcuts

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