From 19a2c02e9a72754d3808cf8fed7ab6133b6912df Mon Sep 17 00:00:00 2001 From: Yanislav Igonin Date: Mon, 4 Oct 2021 19:37:33 +0300 Subject: [PATCH] feat: add captcha check --- controllers/threads_controller.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/controllers/threads_controller.go b/controllers/threads_controller.go index ab16f7d..2e7e686 100644 --- a/controllers/threads_controller.go +++ b/controllers/threads_controller.go @@ -108,6 +108,15 @@ func CreateThread(c *gin.Context) { return } + captchaID := form.Value["captchaId"][0] + captchaString := form.Value["captcha"][0] + isCaptchaValid := captcha.VerifyString(captchaID, captchaString) + if !isCaptchaValid { + log.Println("error:", err) + c.HTML(http.StatusInternalServerError, "400.html", nil) + return + } + // TODO: dat shit crashes if no fields in request text := form.Value["text"][0] title := form.Value["title"][0] @@ -219,6 +228,15 @@ func UpdateThread(c *gin.Context) { return } + captchaID := form.Value["captchaId"][0] + captchaString := form.Value["captcha"][0] + isCaptchaValid := captcha.VerifyString(captchaID, captchaString) + if !isCaptchaValid { + log.Println("error:", err) + c.HTML(http.StatusInternalServerError, "400.html", nil) + return + } + // TODO: dat shit crashes if no fields in request text := form.Value["text"][0] // title := form.Value["title"][0]