captcha

package
v0.0.36 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//验证码
	CaptchaGetParamsInvalidMsg    string = "获取验证码:提交的验证码参数无效,请检查验证码ID以及文件名后缀是否完整"
	CaptchaGetParamsInvalidCode   int    = -400350
	CaptchaCheckParamsInvalidMsg  string = "" /* 127-byte string literal not displayed */
	CaptchaCheckParamsInvalidCode int    = -400351
	CaptchaCheckOkMsg             string = "验证码校验通过"
	CaptchaCheckOkCode            int    = 200
	CaptchaCheckFailCode          int    = -400355
	CaptchaCheckFailMsg           string = "图形验证码校验失败"
)

Variables

This section is empty.

Functions

func HandleCaptchaVerify

func HandleCaptchaVerify(force bool) gin.HandlerFunc

func Init

func Init()

Types

type Base64CaptchaStoreAdapter

type Base64CaptchaStoreAdapter struct {
	base64Captcha.Store
	CodeStore code.CodeStore
}

func (*Base64CaptchaStoreAdapter) Get

func (a *Base64CaptchaStoreAdapter) Get(id string, clear bool) string

Get returns stored digits for the captcha id. Clear indicates whether the captcha must be deleted from the store.

func (*Base64CaptchaStoreAdapter) Set

func (a *Base64CaptchaStoreAdapter) Set(id string, value string) error

Set sets the digits for the captcha id.

func (*Base64CaptchaStoreAdapter) Verify

func (a *Base64CaptchaStoreAdapter) Verify(id, answer string, clear bool) bool

Verify captcha's answer directly

type Captcha

type Captcha struct {
	Id      string `json:"id"`
	Type    string `json:"type"`
	Image   string `json:"image,omitempty"`
	Width   int    `json:"width"`
	Height  int    `json:"height"`
	Length  int    `json:"length"`
	Enabled bool   `json:"enabled"`
}

type CaptchaController

type CaptchaController struct {
	controller.ResourceController
	CaptchaService *CaptchaService `inject:"captchaService"`
}

func (*CaptchaController) CheckCode

func (c *CaptchaController) CheckCode(context *gin.Context)

校验验证码

func (*CaptchaController) Generate

func (c *CaptchaController) Generate(context *gin.Context)

生成验证码

func (*CaptchaController) GetImg

func (c *CaptchaController) GetImg(context *gin.Context)

获取验证码图像

func (*CaptchaController) InitRouter

func (c *CaptchaController) InitRouter(g *gin.RouterGroup) *gin.RouterGroup

type CaptchaForm

type CaptchaForm struct {
	CaptchaId    string `form:"captcha_id" json:"captcha_id"`
	CaptchaValue string `form:"captcha_value" json:"captcha_value"`
}

type CaptchaService

type CaptchaService struct {
	Store code.CodeStore `inject:"captchaCodeStore"`
	// contains filtered or unexported fields
}

func (*CaptchaService) Generate

func (s *CaptchaService) Generate(gtype string) (*Captcha, error)

func (*CaptchaService) Init

func (s *CaptchaService) Init()

func (*CaptchaService) Verify

func (s *CaptchaService) Verify(id, value string) bool

type CaptchaStoreAdpter

type CaptchaStoreAdpter struct {
	captcha.Store
	CodeStore code.CodeStore
}

func (*CaptchaStoreAdpter) Get

func (a *CaptchaStoreAdpter) Get(id string, clear bool) (digits []byte)

Get returns stored digits for the captcha id. Clear indicates whether the captcha must be deleted from the store.

func (*CaptchaStoreAdpter) Set

func (a *CaptchaStoreAdpter) Set(id string, digits []byte)

Set sets the digits for the captcha id.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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