Beego/adapter/utils/captcha
Ming Deng 14c1b76569 remove pkg directory;
remove build directory;
remove githook directory;
2020-10-08 18:29:36 +08:00
..
LICENSE remove pkg directory; 2020-10-08 18:29:36 +08:00
README.md remove pkg directory; 2020-10-08 18:29:36 +08:00
captcha.go remove pkg directory; 2020-10-08 18:29:36 +08:00
image.go remove pkg directory; 2020-10-08 18:29:36 +08:00
image_test.go remove pkg directory; 2020-10-08 18:29:36 +08:00

README.md

Captcha

an example for use captcha

package controllers

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/cache"
	"github.com/astaxie/beego/utils/captcha"
)

var cpt *captcha.Captcha

func init() {
	// use beego cache system store the captcha data
	store := cache.NewMemoryCache()
	cpt = captcha.NewWithFilter("/captcha/", store)
}

type MainController struct {
	beego.Controller
}

func (this *MainController) Get() {
	this.TplName = "index.tpl"
}

func (this *MainController) Post() {
	this.TplName = "index.tpl"

	this.Data["Success"] = cpt.VerifyReq(this.Ctx.Request)
}

template usage

{{.Success}}
<form action="/" method="post">
	{{create_captcha}}
	<input name="captcha" type="text">
</form>