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.
|
||||
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
|
||||
// Answer returns a pregenerated answer.
|
||||
Answer() Answer
|
||||
@ -37,14 +38,14 @@ type Captcha interface {
|
||||
// All derivatives that embed this struct only need to implement
|
||||
// an Image() method.
|
||||
type BaseCaptcha struct {
|
||||
answer Answer
|
||||
solved bool
|
||||
expireIn time.Time
|
||||
answer Answer
|
||||
solved bool
|
||||
expiry time.Time
|
||||
}
|
||||
|
||||
func NewBaseCaptcha(expiry time.Duration) *BaseCaptcha {
|
||||
return &BaseCaptcha{
|
||||
expireIn: ExpiryDate(expiry),
|
||||
expiry: ExpiryDate(expiry),
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,8 +53,6 @@ func (c *BaseCaptcha) Image(style string) *image.Image {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Answer generates an integer answer for a CAPTCHA or just returns
|
||||
// an existing one.
|
||||
func (c *BaseCaptcha) Answer() Answer {
|
||||
if c.answer == "" {
|
||||
c.answer = NewIntAnswer()
|
||||
@ -61,8 +60,6 @@ func (c *BaseCaptcha) Answer() 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 {
|
||||
c.solved = c.answer == answer
|
||||
return c.solved
|
||||
@ -73,7 +70,7 @@ func (c *BaseCaptcha) IsSolved() bool {
|
||||
}
|
||||
|
||||
func (c *BaseCaptcha) Expiry() time.Time {
|
||||
return c.expireIn
|
||||
return c.expiry
|
||||
}
|
||||
|
||||
// ExpiryDate returns a date when CAPTCHA expires. It adds a passed
|
||||
|
Loading…
Reference in New Issue
Block a user