From dea4148f4b12982c897c9e7abf5f62c71af94198 Mon Sep 17 00:00:00 2001 From: Tim Schuster Date: Wed, 22 Apr 2020 07:24:13 +0200 Subject: [PATCH] ignore captcha when creatig new thread --- http/board/newthread.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/http/board/newthread.go b/http/board/newthread.go index 02031a8..a40b3df 100644 --- a/http/board/newthread.go +++ b/http/board/newthread.go @@ -2,12 +2,14 @@ package board import ( "fmt" + "net/http" + "github.com/pressly/chi" "github.com/tidwall/buntdb" + "go.rls.moe/nyx/config" "go.rls.moe/nyx/http/errw" "go.rls.moe/nyx/http/middle" "go.rls.moe/nyx/resources" - "net/http" ) func handleNewThread(w http.ResponseWriter, r *http.Request) { @@ -22,12 +24,14 @@ func handleNewThread(w http.ResponseWriter, r *http.Request) { return } - if !resources.VerifyCaptcha(r) { - http.Redirect(w, r, - fmt.Sprintf("/%s/board.html?err=wrong_captcha", - chi.URLParam(r, "board")), - http.StatusSeeOther) - return + if middle.GetConfig(r).Captcha.Mode != config.CaptchaDisabled { + if !resources.VerifyCaptcha(r) { + http.Redirect(w, r, + fmt.Sprintf("/%s/board.html?err=wrong_captcha", + chi.URLParam(r, "board")), + http.StatusSeeOther) + return + } } var thread = &resources.Thread{}