From 218070fceb86509ddc579fbfa460c78d61c340b8 Mon Sep 17 00:00:00 2001 From: Azareal Date: Tue, 16 Oct 2018 20:02:51 +1000 Subject: [PATCH] Added the DisableJSAntispam config.json setting. --- common/site.go | 1 + routes/account.go | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/common/site.go b/common/site.go index 4a075092..2258328e 100644 --- a/common/site.go +++ b/common/site.go @@ -82,6 +82,7 @@ type config struct { ServerCount int DisableLiveTopicList bool + DisableJSAntispam bool Noavatar string // ? - Move this into the settings table? ItemsPerPage int // ? - Move this into the settings table? diff --git a/routes/account.go b/routes/account.go index b63198d3..8efb3b02 100644 --- a/routes/account.go +++ b/routes/account.go @@ -240,11 +240,13 @@ func AccountRegisterSubmit(w http.ResponseWriter, r *http.Request, user common.U if r.PostFormValue("tos") != "0" { regError(common.GetErrorPhrase("register_might_be_machine"), "trap-question") } - h := sha256.New() - h.Write([]byte(common.JSTokenBox.Load().(string))) - h.Write([]byte(user.LastIP)) - if r.PostFormValue("golden-watch") != hex.EncodeToString(h.Sum(nil)) { - regError(common.GetErrorPhrase("register_might_be_machine"), "js-antispam") + if !common.Config.DisableJSAntispam { + h := sha256.New() + h.Write([]byte(common.JSTokenBox.Load().(string))) + h.Write([]byte(user.LastIP)) + if r.PostFormValue("golden-watch") != hex.EncodeToString(h.Sum(nil)) { + regError(common.GetErrorPhrase("register_might_be_machine"), "js-antispam") + } } username := common.SanitiseSingleLine(r.PostFormValue("username"))