dkforest

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

commit 972658caafe75156324c46546b0490b43b6e94dc
parent 32401db3e4e4351f998a7fd20b0a31b35dc453da
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Thu, 22 Jun 2023 10:04:58 -0700

remove referer calls

Diffstat:
Mpkg/web/handlers/admin.go | 6+++---
Mpkg/web/handlers/forum.go | 2+-
Mpkg/web/handlers/settings.go | 14+++++++-------
3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/pkg/web/handlers/admin.go b/pkg/web/handlers/admin.go @@ -234,7 +234,7 @@ func AdminDeleteDownloadHandler(c echo.Context) error { downloadID, err := utils.ParseInt64(c.Param("downloadID")) if err != nil { return c.Render(http.StatusOK, "flash", - FlashResponse{"download id not found", hutils.GetReferer(c), "alert-danger"}) + FlashResponse{"download id not found", "/admin/downloads", "alert-danger"}) } if err := db.DeleteDownloadByID(downloadID); err != nil { @@ -498,11 +498,11 @@ func AdminDeleteUserHandler(c echo.Context) error { userID, err := dutils.ParseUserID(c.Param("userID")) if err != nil { return c.Render(http.StatusOK, "flash", - FlashResponse{"user id not found", hutils.GetReferer(c), "alert-danger"}) + FlashResponse{"user id not found", "/admin/users", "alert-danger"}) } if userID == config.RootAdminID { return c.Render(http.StatusOK, "flash", - FlashResponse{"Root admin cannot be deleted", hutils.GetReferer(c), "alert-danger"}) + FlashResponse{"Root admin cannot be deleted", "/admin/users", "alert-danger"}) } if err := db.DeleteUserByID(userID); err != nil { diff --git a/pkg/web/handlers/forum.go b/pkg/web/handlers/forum.go @@ -337,7 +337,7 @@ func NewThreadHandler(c echo.Context) error { authUser := c.Get("authUser").(*database.User) db := c.Get("database").(*database.DkfDB) if !authUser.CanUseForumFn() { - return c.Render(http.StatusOK, "flash", FlashResponse{Message: hutils.AccountTooYoungErr.Error(), Redirect: hutils.GetReferer(c), Type: "alert-danger"}) + return c.Render(http.StatusOK, "flash", FlashResponse{Message: hutils.AccountTooYoungErr.Error(), Redirect: "/forum", Type: "alert-danger"}) } var data newThreadData diff --git a/pkg/web/handlers/settings.go b/pkg/web/handlers/settings.go @@ -182,7 +182,7 @@ func changeSettingsForm(c echo.Context, data settingsChatData) error { return c.Render(http.StatusOK, "settings.chat", data) } - return c.Render(http.StatusOK, "flash", FlashResponse{Message: "Settings changed successfully", Redirect: hutils.GetReferer(c)}) + return c.Render(http.StatusOK, "flash", FlashResponse{Message: "Settings changed successfully", Redirect: "/settings/chat"}) } func SettingsSecurityHandler(c echo.Context) error { @@ -254,7 +254,7 @@ func changeUsernameForm(c echo.Context, data settingsAccountData) error { } db.CreateSecurityLog(authUser.ID, database.UsernameChangedSecurityLog) - return c.Render(http.StatusOK, "flash", FlashResponse{Message: "Username changed successfully", Redirect: hutils.GetReferer(c)}) + return c.Render(http.StatusOK, "flash", FlashResponse{Message: "Username changed successfully", Redirect: "/settings/account"}) } func editProfileForm(c echo.Context, data settingsAccountData) error { @@ -286,7 +286,7 @@ func editProfileForm(c echo.Context, data settingsAccountData) error { authUser.TerminateAllSessionsOnLogout = data.TerminateAllSessionsOnLogout authUser.DoSave(db) - return c.Render(http.StatusOK, "flash", FlashResponse{Message: "Profile changed successfully", Redirect: hutils.GetReferer(c)}) + return c.Render(http.StatusOK, "flash", FlashResponse{Message: "Profile changed successfully", Redirect: "/settings/account"}) } func changeAvatarForm(c echo.Context, data settingsAccountData) error { @@ -350,7 +350,7 @@ func changeAvatarForm(c echo.Context, data settingsAccountData) error { authUser.SetAvatar(fileBytes) authUser.DoSave(db) - return c.Render(http.StatusOK, "flash", FlashResponse{Message: "Avatar changed successfully", Redirect: hutils.GetReferer(c)}) + return c.Render(http.StatusOK, "flash", FlashResponse{Message: "Avatar changed successfully", Redirect: "/settings/account"}) } func SettingsChatPMHandler(c echo.Context) error { @@ -497,7 +497,7 @@ func SettingsPublicNotesHandler(c echo.Context) error { authUser := c.Get("authUser").(*database.User) db := c.Get("database").(*database.DkfDB) if !authUser.CanUseForumFn() { - return c.Render(http.StatusOK, "flash", FlashResponse{Message: hutils.AccountTooYoungErr.Error(), Redirect: hutils.GetReferer(c), Type: "alert-danger"}) + return c.Render(http.StatusOK, "flash", FlashResponse{Message: hutils.AccountTooYoungErr.Error(), Redirect: "/settings/public-notes", Type: "alert-danger"}) } var data settingsPublicNotesData data.ActiveTab = "notes" @@ -519,7 +519,7 @@ func SettingsPrivateNotesHandler(c echo.Context) error { authUser := c.Get("authUser").(*database.User) db := c.Get("database").(*database.DkfDB) if !authUser.CanUseForumFn() { - return c.Render(http.StatusOK, "flash", FlashResponse{Message: hutils.AccountTooYoungErr.Error(), Redirect: hutils.GetReferer(c), Type: "alert-danger"}) + return c.Render(http.StatusOK, "flash", FlashResponse{Message: hutils.AccountTooYoungErr.Error(), Redirect: "/settings/private-notes", Type: "alert-danger"}) } var data settingsPrivateNotesData data.ActiveTab = "notes" @@ -1004,5 +1004,5 @@ func SettingsSecretPhraseHandler(c echo.Context) error { authUser.DoSave(db) db.CreateSecurityLog(authUser.ID, database.ChangeSecretPhraseSecurityLog) - return c.Render(http.StatusFound, "flash", FlashResponse{Message: "Secret phrase changed successfully", Redirect: hutils.GetReferer(c)}) + return c.Render(http.StatusFound, "flash", FlashResponse{Message: "Secret phrase changed successfully", Redirect: "/"}) }