1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-24 12:40:55 +00:00
Beego/pkg/utils/captcha
2020-08-18 14:31:06 +00:00
..
captcha.go Refactor orm filter 2020-08-18 14:31:06 +00:00
image_test.go uing pkg module 2020-07-29 14:42:27 +00:00
image.go Move package 2020-07-22 22:55:59 +08:00
LICENSE Move package 2020-07-22 22:55:59 +08:00
README.md Move package 2020-07-22 22:55:59 +08:00
siprng_test.go Move package 2020-07-22 22:55:59 +08:00
siprng.go Move package 2020-07-22 22:55:59 +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>