CAPTCHA implementation changed to a new interface. And now composes from BaseCaptcha struct.
This commit is contained in:
parent
f7439eb282
commit
f35c16f837
@ -15,16 +15,16 @@ const (
|
||||
)
|
||||
|
||||
type DwellingCaptcha struct {
|
||||
captcha.Captcha
|
||||
captcha.BaseCaptcha
|
||||
}
|
||||
|
||||
func NewDwellingCaptcha(expiry time.Duration) *DwellingCaptcha {
|
||||
return &DwellingCaptcha{
|
||||
Captcha: captcha.Captcha{
|
||||
BaseCaptcha: captcha.BaseCaptcha{
|
||||
ExpireIn: captcha.ExpiryDate(expiry)}}
|
||||
}
|
||||
|
||||
func (c *DwellingCaptcha) generateImage(style string) *image.Image {
|
||||
func (c *DwellingCaptcha) Image(style string) image.Image {
|
||||
isDark := style == "dark"
|
||||
ctx := gg.NewContext(dwImageWidth, dwImageHeight)
|
||||
|
||||
@ -67,14 +67,5 @@ func (c *DwellingCaptcha) generateImage(style string) *image.Image {
|
||||
ctx.Stroke()
|
||||
}
|
||||
|
||||
c.Image = ctx.Image()
|
||||
return &c.Image
|
||||
}
|
||||
|
||||
func (c *DwellingCaptcha) GetImage(style string) *image.Image {
|
||||
if c.Image == nil {
|
||||
return c.generateImage(style)
|
||||
}
|
||||
|
||||
return &c.Image
|
||||
return ctx.Image()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user