Field expireIn -> expiry. Comments were redacted.
This commit is contained in:
parent
d9aba868db
commit
cc30010d3f
@ -20,7 +20,8 @@ func NewIntAnswer() Answer {
|
|||||||
|
|
||||||
// Captcha interface that should be implemented by a CAPTCHA.
|
// Captcha interface that should be implemented by a CAPTCHA.
|
||||||
type Captcha interface {
|
type Captcha interface {
|
||||||
// Image generates and returns a pointer to an image of CAPTCHA.
|
// Image generates an image of a CAPTCHA according to a passed style
|
||||||
|
// and returns a pointer to it.
|
||||||
Image(style string) *image.Image
|
Image(style string) *image.Image
|
||||||
// Answer returns a pregenerated answer.
|
// Answer returns a pregenerated answer.
|
||||||
Answer() Answer
|
Answer() Answer
|
||||||
@ -39,12 +40,12 @@ type Captcha interface {
|
|||||||
type BaseCaptcha struct {
|
type BaseCaptcha struct {
|
||||||
answer Answer
|
answer Answer
|
||||||
solved bool
|
solved bool
|
||||||
expireIn time.Time
|
expiry time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBaseCaptcha(expiry time.Duration) *BaseCaptcha {
|
func NewBaseCaptcha(expiry time.Duration) *BaseCaptcha {
|
||||||
return &BaseCaptcha{
|
return &BaseCaptcha{
|
||||||
expireIn: ExpiryDate(expiry),
|
expiry: ExpiryDate(expiry),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,8 +53,6 @@ func (c *BaseCaptcha) Image(style string) *image.Image {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Answer generates an integer answer for a CAPTCHA or just returns
|
|
||||||
// an existing one.
|
|
||||||
func (c *BaseCaptcha) Answer() Answer {
|
func (c *BaseCaptcha) Answer() Answer {
|
||||||
if c.answer == "" {
|
if c.answer == "" {
|
||||||
c.answer = NewIntAnswer()
|
c.answer = NewIntAnswer()
|
||||||
@ -61,8 +60,6 @@ func (c *BaseCaptcha) Answer() Answer {
|
|||||||
return c.answer
|
return c.answer
|
||||||
}
|
}
|
||||||
|
|
||||||
// Solve sets solved field to true if given answer is right and returns a result
|
|
||||||
// of a check.
|
|
||||||
func (c *BaseCaptcha) Solve(answer Answer) bool {
|
func (c *BaseCaptcha) Solve(answer Answer) bool {
|
||||||
c.solved = c.answer == answer
|
c.solved = c.answer == answer
|
||||||
return c.solved
|
return c.solved
|
||||||
@ -73,7 +70,7 @@ func (c *BaseCaptcha) IsSolved() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *BaseCaptcha) Expiry() time.Time {
|
func (c *BaseCaptcha) Expiry() time.Time {
|
||||||
return c.expireIn
|
return c.expiry
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExpiryDate returns a date when CAPTCHA expires. It adds a passed
|
// ExpiryDate returns a date when CAPTCHA expires. It adds a passed
|
||||||
|
Loading…
Reference in New Issue
Block a user