Expiration time now being get from CaptchaDB.

This commit is contained in:
Alexander Andreev 2022-06-26 15:45:42 +04:00
parent c5d159531c
commit 4af8d67299
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F
1 changed files with 4 additions and 8 deletions

View File

@ -6,20 +6,16 @@ import (
"justcaptcha/internal/captcha"
"justcaptcha/pkg/server"
"net/http"
"time"
)
type CaptchaHandlers struct {
ExpireIn time.Duration
}
type CaptchaHandlers struct{}
func New(expiration time.Duration) *CaptchaHandlers {
return &CaptchaHandlers{
ExpireIn: expiration}
func New() *CaptchaHandlers {
return &CaptchaHandlers{}
}
func (h *CaptchaHandlers) New(w http.ResponseWriter, r *http.Request) {
dc := captcha.NewDwellingCaptcha(h.ExpireIn)
dc := captcha.NewDwellingCaptcha(captcha.GetExpireInterval())
_, id := captcha.New(r.RemoteAddr, dc)
fmt.Fprint(w, id)