dkforest

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

commit 26f106ea578c517618a98b9c6d05027e36839e8e
parent 68cebecab91f74e9e84b81c8b3df5c4d927d41a8
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Mon, 12 Dec 2022 21:26:36 -0500

simplify code

Diffstat:
Mpkg/database/tableUsers.go | 4++++
Mpkg/web/middlewares/middlewares.go | 2+-
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/pkg/database/tableUsers.go b/pkg/database/tableUsers.go @@ -15,6 +15,10 @@ import ( type UserID int64 +func (u UserID) String() string { + return utils.FormatInt64(int64(u)) +} + // User struct an internal representation of a user for our app type User struct { ID UserID diff --git a/pkg/web/middlewares/middlewares.go b/pkg/web/middlewares/middlewares.go @@ -82,7 +82,7 @@ func GenericRateLimitMiddleware(period time.Duration, limit int64) echo.Middlewa return func(c echo.Context) error { key := "ip_" + c.RealIP() if authUser, ok := c.Get("authUser").(*database.User); ok && authUser != nil { - key = "userid_" + utils.FormatInt64(int64(authUser.ID)) + key = "userid_" + authUser.ID.String() } else if conn, ok := c.Request().Context().Value("conn").(net.Conn); ok { circuitID := config.ConnMap.Get(conn) key = "circuitid_" + utils.FormatInt64(circuitID)