dkforest

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

commit 8fa1fdc6d9d8ce688044a8ef8251387e46f9abbd
parent f8dca7b0318727797e13c1a01848cc79da02cdf5
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Sat, 27 May 2023 21:23:57 -0700

fix

Diffstat:
Mpkg/web/handlers/chat.go | 2+-
Mpkg/web/handlers/handlers.go | 2+-
Mpkg/web/handlers/utils/utils.go | 5++---
3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/pkg/web/handlers/chat.go b/pkg/web/handlers/chat.go @@ -197,7 +197,7 @@ func handleChatPasswordPost(db *database.DkfDB, c echo.Context, data chatData, a // verify POW if config.PowEnabled.IsTrue() { - if !hutils.VerifyPow(database.Username(data.GuestUsername), data.Pow, config.PowDifficulty) { + if !hutils.VerifyPow(data.GuestUsername, data.Pow, config.PowDifficulty) { data.ErrPow = "invalid proof of work" return c.Render(http.StatusOK, chatPasswordTmplName, data) } diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -878,7 +878,7 @@ func signupHandler(c echo.Context) error { // verify POW if config.PowEnabled.IsTrue() { - if !hutils.VerifyPow(database.Username(data.Username), data.Pow, config.PowDifficulty) { + if !hutils.VerifyPow(data.Username, data.Pow, config.PowDifficulty) { data.ErrPow = "invalid proof of work" return c.Render(http.StatusOK, "standalone.signup", data) } diff --git a/pkg/web/handlers/utils/utils.go b/pkg/web/handlers/utils/utils.go @@ -3,7 +3,6 @@ package utils import ( "crypto/sha256" "dkforest/pkg/captcha" - "dkforest/pkg/database" "encoding/base64" "encoding/hex" "encoding/json" @@ -179,8 +178,8 @@ func KillCircuit(c echo.Context) { } } -func VerifyPow(username database.Username, nonce string, difficulty int) bool { - h := sha256.Sum256([]byte(string(username) + ":" + nonce)) +func VerifyPow(username, nonce string, difficulty int) bool { + h := sha256.Sum256([]byte(username + ":" + nonce)) hashed := hex.EncodeToString(h[:]) prefix := strings.Repeat("0", difficulty) return strings.HasPrefix(hashed, prefix)