dkforest

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

commit 80f25e998640283b01f29cc99e8c9f830b86325c
parent 6403dfd1f9578ea00e1034bac51d0d145ae3baad
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Wed, 11 Jan 2023 10:31:08 -0800

add doc

Diffstat:
Mpkg/web/handlers/chat.go | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/pkg/web/handlers/chat.go b/pkg/web/handlers/chat.go @@ -130,6 +130,8 @@ func chatHandler(c echo.Context, redRoom bool) error { func handleChatPasswordPost(c echo.Context, data chatData, authUser *database.User, room database.ChatRoom) error { data.RoomPassword = c.Request().PostFormValue("password") + + // If no user set, we verify the captcha and username for the guest account if authUser == nil { data.GuestUsername = c.Request().PostFormValue("guest_username") captchaID := c.Request().PostFormValue("captcha_id") @@ -144,6 +146,8 @@ func handleChatPasswordPost(c echo.Context, data chatData, authUser *database.Us return c.Render(http.StatusOK, "chat-password", data) } } + + // Verify room password is correct key := utils.Sha256([]byte(config.RoomPasswordSalt + data.RoomPassword))[:32] hashedPassword := utils.Sha512([]byte(config.RoomPasswordSalt + data.RoomPassword)) if hashedPassword != room.Password { @@ -151,6 +155,8 @@ func handleChatPasswordPost(c echo.Context, data chatData, authUser *database.Us return c.Render(http.StatusOK, "chat-password", data) } + // If no user set, create the guest account + session + // TODO: maybe add "_guest" suffix to guest accounts? if authUser == nil { password := utils.GenerateToken32() newUser, errs := database.CreateGuestUser(data.GuestUsername, password)