From 2f9e26d799b41ad65627ea2bb1a3958401d106e6 Mon Sep 17 00:00:00 2001 From: Yanislav Igonin Date: Wed, 9 Feb 2022 09:18:51 +0200 Subject: [PATCH] feat: disable captcha for local dev --- controllers/threads_controller.go | 36 +++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/controllers/threads_controller.go b/controllers/threads_controller.go index e930d14..7c501be 100644 --- a/controllers/threads_controller.go +++ b/controllers/threads_controller.go @@ -119,15 +119,17 @@ func CreateThread(c *gin.Context) { return } - captchaID := form.Value["captchaId"][0] - captchaString := form.Value["captcha"][0] - isCaptchaValid := captcha.VerifyString(captchaID, captchaString) - if !isCaptchaValid { - errorHtmlData := Repositories.BadRequestHtmlData{ - Message: Repositories.InvalidCaptchaErrorMessage, + if Config.App.IsCaptchaActive { + captchaID := form.Value["captchaId"][0] + captchaString := form.Value["captcha"][0] + isCaptchaValid := captcha.VerifyString(captchaID, captchaString) + if !isCaptchaValid { + errorHtmlData := Repositories.BadRequestHtmlData{ + Message: Repositories.InvalidCaptchaErrorMessage, + } + c.HTML(http.StatusBadRequest, "400.html", errorHtmlData) + return } - c.HTML(http.StatusBadRequest, "400.html", errorHtmlData) - return } conn, err := Db.Pool.Acquire(context.TODO()) @@ -279,15 +281,17 @@ func UpdateThread(c *gin.Context) { return } - captchaID := form.Value["captchaId"][0] - captchaString := form.Value["captcha"][0] - isCaptchaValid := captcha.VerifyString(captchaID, captchaString) - if !isCaptchaValid { - errorHtmlData := Repositories.BadRequestHtmlData{ - Message: Repositories.InvalidCaptchaErrorMessage, + if Config.App.IsCaptchaActive { + captchaID := form.Value["captchaId"][0] + captchaString := form.Value["captcha"][0] + isCaptchaValid := captcha.VerifyString(captchaID, captchaString) + if !isCaptchaValid { + errorHtmlData := Repositories.BadRequestHtmlData{ + Message: Repositories.InvalidCaptchaErrorMessage, + } + c.HTML(http.StatusBadRequest, "400.html", errorHtmlData) + return } - c.HTML(http.StatusBadRequest, "400.html", errorHtmlData) - return } isSageField := form.Value["sage"]