dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 0a5e62d4d4654d62aa3413bf8f5031780ea7338f
parent b2044785bec4c5b66b45b6521674b72d56105d0c
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Wed, 18 Jan 2023 20:13:48 -0800

cleanup

Diffstat:
Mpkg/web/handlers/data.go | 13++++---------
Mpkg/web/handlers/handlers.go | 7+++++--
Mpkg/web/middlewares/data.go | 7++++---
Mpkg/web/middlewares/middlewares.go | 1+
Mpkg/web/public/views/pages/captcha-required.gohtml | 2+-
5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/pkg/web/handlers/data.go b/pkg/web/handlers/data.go @@ -411,9 +411,10 @@ type captchaData struct { } type captchaRequiredData struct { - CaptchaID string - CaptchaImg string - ErrCaptcha string + CaptchaDescription string + CaptchaID string + CaptchaImg string + ErrCaptcha string } type bhcData struct { @@ -643,12 +644,6 @@ type settingsUploadsData struct { Files []database.Upload } -type uploadsDownloadData struct { - CaptchaID string - CaptchaImg string - ErrCaptcha string -} - type settingsPublicNotesData struct { ActiveTab string Notes database.UserPublicNote diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -1254,7 +1254,8 @@ func LinksDownloadHandler(c echo.Context) error { fileName := "dkf_links.csv" // Captcha for bigger files - var data uploadsDownloadData + var data captchaRequiredData + data.CaptchaDescription = "Captcha required" data.CaptchaID, data.CaptchaImg = captcha.New() const captchaRequiredTmpl = "captcha-required" if c.Request().Method == http.MethodGet { @@ -3629,6 +3630,7 @@ func CaptchaRequiredHandler(c echo.Context) error { authUser := c.Get("authUser").(*database.User) var data captchaRequiredData + data.CaptchaDescription = "Captcha required" data.CaptchaID, data.CaptchaImg = captcha.New() config.CaptchaRequiredGenerated.Inc() @@ -3800,7 +3802,8 @@ func UploadsDownloadHandler(c echo.Context) error { // Display captcha to new users, or old users if they already downloaded the file. if !authUser.AccountOldEnough() || database.UserNbDownloaded(authUser.ID, filename) >= 1 { // Captcha for bigger files - var data uploadsDownloadData + var data captchaRequiredData + data.CaptchaDescription = "Captcha required" data.CaptchaID, data.CaptchaImg = captcha.New() const captchaRequiredTmpl = "captcha-required" if c.Request().Method == http.MethodGet { diff --git a/pkg/web/middlewares/data.go b/pkg/web/middlewares/data.go @@ -5,7 +5,8 @@ type unauthorizedData struct { } type captchaMiddlewareData struct { - CaptchaID string - CaptchaImg string - ErrCaptcha string + CaptchaDescription string + CaptchaID string + CaptchaImg string + ErrCaptcha string } diff --git a/pkg/web/middlewares/middlewares.go b/pkg/web/middlewares/middlewares.go @@ -56,6 +56,7 @@ func CaptchaMiddleware() echo.MiddlewareFunc { return func(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { var data captchaMiddlewareData + data.CaptchaDescription = "Captcha required" data.CaptchaID, data.CaptchaImg = captcha.New() const captchaRequiredTmpl = "captcha-required" if c.Request().Method == http.MethodPost { diff --git a/pkg/web/public/views/pages/captcha-required.gohtml b/pkg/web/public/views/pages/captcha-required.gohtml @@ -13,7 +13,7 @@ <div class="row"> <div class="col-sm-12 col-md-10 offset-md-1"> <div class="form-group"> - <label for="captcha">Captcha required</label> + <label for="captcha">{{ .Data.CaptchaDescription }}</label> <div class="mb-2 text-center"> {{ template "captcha-tmpl" . }} </div>