diff --git a/pkg/captcha/captcha.go b/pkg/captcha/captcha.go index 8fce4fc..141fd6d 100644 --- a/pkg/captcha/captcha.go +++ b/pkg/captcha/captcha.go @@ -68,6 +68,9 @@ func (c *Captcha) Solve(answer Answer) bool { } func (c *Captcha) GetAnswer() Answer { + if c.Answer == "" { + c.Answer = generateAnswer() + } return c.Answer } @@ -79,7 +82,7 @@ func (c *Captcha) Expiry() time.Time { return c.ExpireIn } -func GenerateAnswer() Answer { +func generateAnswer() Answer { ans, _ := rand.Int(rand.Reader, big.NewInt(maxAnswer)) return (Answer(ans.String())) }