captcha

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: AGPL-3.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TypeDefault = `default`
	TypeAPI     = `api`
)

Variables

View Source
var (
	//ErrCaptcha 验证码错误
	ErrCaptcha = echo.NewError(`Captcha is incorrect`, code.CaptchaError)
	//ErrCaptchaIdMissing 缺少captchaId
	ErrCaptchaIdMissing = echo.NewError(`Missing captchaId`, code.CaptchaIdMissing).SetZone(`captchaId`)
	//ErrCaptchaCodeRequired 验证码不能为空
	ErrCaptchaCodeRequired = echo.NewError(`Captcha code is required`, code.CaptchaCodeRequired).SetZone(`code`)
)

Functions

func GenAndRecordCaptchaID

func GenAndRecordCaptchaID(ctx echo.Context, opt *hdlCaptcha.Options) string

func GenCaptchaError

func GenCaptchaError(ctx echo.Context, err error, captchaName string, data interface{}) echo.Data

func Get

func Get(name string) func() ICaptcha

func GetAllNames

func GetAllNames() []string

func GetCaptchaID

func GetCaptchaID(ctx echo.Context, opt *hdlCaptcha.Options, id string) (string, error)

func GetHistoryOrNewCaptchaID

func GetHistoryOrNewCaptchaID(ctx echo.Context, opt *hdlCaptcha.Options) string

func GetOk

func GetOk(name string) (func() ICaptcha, bool)

func Has

func Has(name string) bool

func Register

func Register(name string, ic func() ICaptcha)

func RenderTemplate

func RenderTemplate(ctx echo.Context, captchaType string, templatePath string, options param.Store) template.HTML

Types

type ICaptcha

type ICaptcha interface {
	Init(echo.H) error
	// keysValues: key1, value1, key2, value2
	Render(ctx echo.Context, templatePath string, keysValues ...interface{}) template.HTML
	Verify(ctx echo.Context, hostAlias string, name string, captchaIdent ...string) echo.Data
	MakeData(ctx echo.Context, hostAlias string, name string) echo.H
}

Jump to

Keyboard shortcuts

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