player

package
v0.0.0-...-7ee29c8 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtxUUIDKey ctxKey = iota
	CtxUsernameKey
)

Variables

This section is empty.

Functions

func ByUUIDMiddleware

func ByUUIDMiddleware(repo DataRepo) func(h http.Handler) http.Handler

func GetPlayerHandler

func GetPlayerHandler(repo DataRepo) http.HandlerFunc

func GetVerificationsHandler

func GetVerificationsHandler(repo DataRepo) http.HandlerFunc

func PostPlayerHandler

func PostPlayerHandler(repo DataRepo) http.HandlerFunc

func PostVerificationEmailHandler

func PostVerificationEmailHandler(cfg VerificationEmailConfig, mail mailer.Service, repo DataRepo) http.HandlerFunc

func PostVerificationHandler

func PostVerificationHandler(repo DataRepo) http.HandlerFunc

func PostVerificationVerifyHandler

func PostVerificationVerifyHandler(repo DataRepo) http.HandlerFunc

Types

type DataRepo

type DataRepo interface {
	PlayerWithUUIDExists(uuid string) (bool, error)
	PlayerByUUID(uuid string) (Player, error)
	CreatePlayer(p *Player) error

	Verifications(pUUID string) ([]Verification, error)
	CreateVerification(v *Verification) error
	LatestVerification(pUUID string) (Verification, bool, error)
	CreateEmailVerification(ve VerificationEmail) error
	VerifyVerification(vID uint64, code string) (bool, error)
}

type Player

type Player struct {
	UUID       string    `json:"uuid"`
	Username   string    `json:"username"`
	IsVerified bool      `json:"isVerified"`
	CreatedAt  time.Time `json:"createdAt"`
}

func (Player) Validate

func (player Player) Validate() error

type Verification

type Verification struct {
	ID         uint64              `json:"id"`
	PlayerUUID string              `json:"playerUuid,omitempty"`
	Emails     []VerificationEmail `json:"emails,omitempty"`
	IsVerified bool                `json:"isVerified"`
	CreatedAt  time.Time           `json:"createdAt"`
}

type VerificationEmail

type VerificationEmail struct {
	VerificationID uint64     `json:"verificationId"`
	Email          string     `json:"email"`
	Code           string     `json:"code"`
	VerifiedAt     *time.Time `json:"verifiedAt,omitempty"`
	ExpiresAt      *time.Time `json:"expiresAt"`
	CreatedAt      time.Time  `json:"createdAt"`
}

func (VerificationEmail) Validate

func (email VerificationEmail) Validate(emailRegex *regexp.Regexp) error

type VerificationEmailCode

type VerificationEmailCode struct {
	Code string `json:"code"`
}

func (VerificationEmailCode) Validate

func (code VerificationEmailCode) Validate() error

type VerificationEmailConfig

type VerificationEmailConfig struct {
	EmailRegex             string
	VerificationCodeLength int
	EmailValidityDuration  time.Duration
	MaxEmailTries          int
}

Jump to

Keyboard shortcuts

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