commit 073681db2b9edcafa82741c060a63174fbd566d4
parent df9407ebf59b080b86ae6c519cf15aecabc2c361
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Fri, 26 May 2023 04:51:36 -0700
cleanup
Diffstat:
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/pkg/database/utils/utils.go b/pkg/database/utils/utils.go
@@ -9,7 +9,6 @@ import (
"fmt"
"github.com/labstack/echo"
"github.com/sirupsen/logrus"
- "net/http"
)
func GetZeroUser(db *database.DkfDB) database.User {
@@ -160,11 +159,11 @@ func GetRoomAndKey(db *database.DkfDB, c echo.Context, roomName string) (databas
roomKey := ""
room, err := db.GetChatRoomByName(roomName)
if err != nil {
- return room, roomKey, c.NoContent(http.StatusNotFound)
+ return room, roomKey, errors.New("room not found")
}
hasAccess, roomKey := room.HasAccess(c)
if !hasAccess {
- return room, roomKey, c.NoContent(http.StatusForbidden)
+ return room, roomKey, errors.New("forbidden")
}
return room, roomKey, nil
}
diff --git a/pkg/web/handlers/api/v1/topBarHandler.go b/pkg/web/handlers/api/v1/topBarHandler.go
@@ -232,7 +232,7 @@ func ChatTopBarHandler(c echo.Context) error {
room, roomKey, err := dutils.GetRoomAndKey(db, c, data.RoomName)
if err != nil {
- return err
+ return c.NoContent(http.StatusForbidden)
}
// If the tutorial is not completed, just render the chat top-bar, no matter what.