Commit 00eac0e4 authored by astaxie's avatar astaxie

Merge pull request #729 from francoishill/patch-9

Update captcha.go
parents 2773fda8 58ac0d5e
......@@ -200,7 +200,7 @@ func (c *Captcha) Verify(id string, challenge string) (success bool) {
key := c.key(id)
if v, ok := c.store.Get(key).([]byte); ok && len(v) == len(challenge) {
if v, ok := c.store.Get(key).([]byte); ok {
chars = v
} else {
return
......@@ -211,6 +211,9 @@ func (c *Captcha) Verify(id string, challenge string) (success bool) {
c.store.Delete(key)
}()
if len(chars) != len(challenge) {
return
}
// verify challenge
for i, c := range chars {
if c != challenge[i]-48 {
......@@ -221,6 +224,7 @@ func (c *Captcha) Verify(id string, challenge string) (success bool) {
return true
}
// create a new captcha.Captcha
func NewCaptcha(urlPrefix string, store cache.Cache) *Captcha {
cpt := &Captcha{}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment