1
0
mirror of https://github.com/astaxie/beego.git synced 2024-06-30 18:04:14 +00:00

Merge pull request #1083 from supiyun/patch-1

验证码reload问题
This commit is contained in:
astaxie 2015-03-30 21:40:57 +08:00
commit 840fd3b64f

View File

@ -132,15 +132,6 @@ func (c *Captcha) Handler(ctx *context.Context) {
key := c.key(id)
if v, ok := c.store.Get(key).([]byte); ok {
chars = v
} else {
ctx.Output.SetStatus(404)
ctx.WriteString("captcha not found")
return
}
// reload captcha
if len(ctx.Input.Query("reload")) > 0 {
chars = c.genRandChars()
if err := c.store.Put(key, chars, c.Expiration); err != nil {
@ -149,6 +140,14 @@ func (c *Captcha) Handler(ctx *context.Context) {
beego.Error("Reload Create Captcha Error:", err)
return
}
} else {
if v, ok := c.store.Get(key).([]byte); ok {
chars = v
} else {
ctx.Output.SetStatus(404)
ctx.WriteString("captcha not found")
return
}
}
img := NewImage(chars, c.StdWidth, c.StdHeight)