diff --git a/docker/oef_regression_test/docker-compose.yaml b/docker/oef_regression_test/docker-compose.yaml index 53e9e955..bacfe0ba 100644 --- a/docker/oef_regression_test/docker-compose.yaml +++ b/docker/oef_regression_test/docker-compose.yaml @@ -12,6 +12,7 @@ services: environment: - DB_HOST=db - DB_PORT=3306 + - OEF_REGRESSION_TEST=1 volumes: - /etc/localtime:/etc/localtime:ro - ../../config/config.regression_test.yaml:/srv/oef/config/config.yaml diff --git a/handlers/handlers.go b/handlers/handlers.go index 817adeb5..099ad642 100644 --- a/handlers/handlers.go +++ b/handlers/handlers.go @@ -179,7 +179,7 @@ func NewHandlers(config *config.ConfigT, renderer map[string]renderer.Renderer, // Captcha - r.Handle("/captcha/{img}", captcha.Server(captcha.StdWidth, captcha.StdHeight)) + r.Handle("/captcha/{img}", handlers.JWTCookieMiddleware.Handler(handlers.Recover(captcha.Server(captcha.StdWidth, captcha.StdHeight)))) // Home diff --git a/orm/school.go b/orm/school.go index b32441a7..feab8c26 100644 --- a/orm/school.go +++ b/orm/school.go @@ -3,6 +3,7 @@ package orm import ( "fmt" "net/http" + "os" "strings" "time" @@ -179,7 +180,7 @@ func (model *School) Create(db *Database, args map[string]string, w http.Respons return school, nil } else { - if isSubscriber(r) { + if isSubscriber(r) && os.Getenv("OEF_REGRESSION_TEST") != "1" { if !captcha.VerifyString(r.FormValue("CaptchaID"), r.FormValue("CaptchaSolution")) { return nil, errors.WrongCaptcha } diff --git a/renderer/funcmap.go b/renderer/funcmap.go index 7fa37db3..ee907b37 100644 --- a/renderer/funcmap.go +++ b/renderer/funcmap.go @@ -6,6 +6,7 @@ import ( "html/template" "io/ioutil" "net/url" + "os" "reflect" "strconv" "strings" @@ -27,6 +28,7 @@ const ( var ( funcMap = template.FuncMap{ + "env": env, "genCaptcha": genCaptcha, "markdown": markdown, "version": version, @@ -74,6 +76,10 @@ var ( } ) +func env(key string) string { + return os.Getenv(key) +} + func genCaptcha() string { return captcha.New() } diff --git a/templates/schools_add_update.html.tpl b/templates/schools_add_update.html.tpl index 9faaf58e..cedf62c6 100644 --- a/templates/schools_add_update.html.tpl +++ b/templates/schools_add_update.html.tpl @@ -22,7 +22,7 @@ {{end}} {{if $isSubscriber}} -{{template "add_update_header" dict "update" $update "addTitle" "Iscrivi la scuola" "updateTitle" (printf "Aggiorna scuola %s" (.Data|string))}} +{{template "add_update_header" dict "update" $update "addTitle" "Iscrivi una nuova scuola" "updateTitle" (printf "Aggiorna scuola %s" (.Data|string))}} {{else}} {{template "add_update_header" dict "update" $update "addTitle" "Crea nuova scuola" "updateTitle" (printf "Aggiorna scuola %s" (.Data|string))}} {{end}} @@ -100,18 +100,20 @@ {{template "input" dict "options" ($options|yaml) "value" (.Data|field "ContestDirectorLastname") "update" $update}} - + + {{if ne (env "OEF_REGRESSION_TEST") "1"}} {{if .Claims|isSubscriber}} {{$captcha := genCaptcha}} -