废话不多说 直接 上代码:
login.go
package controllers
import (
"fmt"
"strings"
"github.com/astaxie/beego"
"github.com/mojocn/base64Captcha"
)
var store = base64Captcha.DefaultMemStore
/*
var store base64Captcha.Store
func init() {
store = base64Captcha.DefaultMemStore
// base64Captcha.DefaultMemStore是默认的:10240 个 过期时间10分钟
// 也可以自己设定参数base64Captcha.NewMemoryStore(GCLimitNumber, Expiration
}
*/
type LoginController struct {
beego.Controller
}
func If(condition bool, trueVal, falseVal interface{
}) interface{
} {
if condition {
return trueVal
} else {
return falseVal
}
}
///获取验证码
func (c *LoginController) Captcha() {
type CaptchaResult struct {
Id