1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-14 07:00:56 +00:00
Beego/utils/captcha
2017-03-17 19:45:30 +02:00
..
captcha.go bee fix 2016-03-25 10:56:15 +08:00
image_test.go update the documents & comments 2014-08-18 16:41:43 +08:00
image.go add unconverted support 2017-03-17 19:45:30 +02:00
LICENSE add missed LICENSE of captcha 2015-05-24 23:59:39 +08:00
README.md TplNames renamed TplName ,fix #1229,Remember modify bee tool. 2016-01-07 16:16:39 +08:00
siprng_test.go update the documents & comments 2014-08-18 16:41:43 +08:00
siprng.go update the documents & comments 2014-08-18 16:41:43 +08:00

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>