users

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrVerificationFailed   = errors.New("user could not be verified")
	ErrInvalidLogin         = errors.New("invalid login")
	ErrUserAccountNotActive = errors.New("user account is not active")
	ErrUserAccountExists    = errors.New("user account already exists")
)

Functions

This section is empty.

Types

type CreateUserParams

type CreateUserParams struct {
	PlayerName string
	Email      string
	Password   string
	// The URL (without the activation token query parameter) that users should call to confirm their activation.
	VerifyURL *url.URL
}

type Service

type Service interface {
	// CreateUser adds a new user to the store.
	// The default implementation sends out a verification email.
	CreateUser(ctx context.Context, ps CreateUserParams) error
	// VerifyUser takes a verification token (typically taken from a URL query
	// parameter of an activation link), checks whether the token is valid,
	// not expired and assigned to a user account awaiting verification.
	// If the checks are successful, the user is marked as verified and
	// can be used to log in.
	// Returns ErrVerificationFailed if the verification itself failed,
	// but was executed without errors,
	VerifyUser(ctx context.Context, token string) error

	ValidateLogin(ctx context.Context, email, password string) (*User, error)
}

type ServiceDefault

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

func NewService

func NewService(store hexzsql.UserStore, mailClient *mail.Client) *ServiceDefault

func (*ServiceDefault) CreateUser

func (s *ServiceDefault) CreateUser(ctx context.Context, ps CreateUserParams) error

func (*ServiceDefault) ValidateLogin

func (s *ServiceDefault) ValidateLogin(ctx context.Context, email, password string) (*User, error)

func (*ServiceDefault) VerifyUser

func (s *ServiceDefault) VerifyUser(ctx context.Context, token string) error

type User

type User struct {
	ID         string
	Email      string
	PlayerName string
}

Jump to

Keyboard shortcuts

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