dkforest

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

commit 81feeb97018e51e4338e77da39c1138674ef43e3
parent 4f3ba46ef785309dbfeb500509d704ba61c0ee89
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Wed,  9 Nov 2022 20:39:47 -0800

cleanup

Diffstat:
Mpkg/database/tableUsers.go | 8++++++--
Mpkg/web/handlers/handlers.go | 4++--
2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/pkg/database/tableUsers.go b/pkg/database/tableUsers.go @@ -451,8 +451,12 @@ func CanUseUsername(username string, isFirstUser bool) error { } // CreateUser ... -func CreateUser(username, password, repassword string, temp bool, registrationDuration int64, signupInfoEnc string) (User, UserErrors) { - return createUser(username, password, repassword, "", false, true, temp, false, false, registrationDuration, signupInfoEnc) +func CreateUser(username, password, repassword string, registrationDuration int64, signupInfoEnc string) (User, UserErrors) { + return createUser(username, password, repassword, "", false, true, false, false, false, registrationDuration, signupInfoEnc) +} + +func CreateGuestUser(username, password string) (User, UserErrors) { + return createUser(username, password, password, "", false, true, true, false, false, 0, "signupInfoEnc") } func CreateFirstUser(username, password, repassword string) (User, UserErrors) { diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -896,7 +896,7 @@ func signupHandler(c echo.Context) error { signupInfoEnc, _ := json.Marshal(signupInfo) registrationDuration := time.Now().UnixMilli() - start - newUser, errs := database.CreateUser(data.Username, data.Password, data.RePassword, false, registrationDuration, string(signupInfoEnc)) + newUser, errs := database.CreateUser(data.Username, data.Password, data.RePassword, registrationDuration, string(signupInfoEnc)) if errs.HasError() { data.Errors = errs return c.Render(http.StatusOK, "signup", data) @@ -2251,7 +2251,7 @@ func chatHandler(c echo.Context, redRoom bool) error { if authUser == nil { password := utils.GenerateToken() - newUser, errs := database.CreateUser(data.GuestUsername, password, password, true, 0, "") + newUser, errs := database.CreateGuestUser(data.GuestUsername, password) if errs.HasError() { data.ErrGuestUsername = errs.Username return c.Render(http.StatusOK, "chat-password", data)