commit 6ff0ea8b4d54b47d87a2a72a0cb3079c3e158d5f
parent d76e5a20a9eaab1716f4d25f67ba10592250164c
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Tue, 13 Dec 2022 22:42:29 -0500
remove useless code
Diffstat:
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/pkg/database/tableSessions.go b/pkg/database/tableSessions.go
@@ -26,7 +26,7 @@ func GetActiveUserSessions(userID UserID) (out []Session) {
}
// CreateSession creates a session for a user
-func CreateSession(userID UserID, realIP, userAgent string) (Session, error) {
+func CreateSession(userID UserID, userAgent string) (Session, error) {
// Delete all sessions except the last 4
if err := DB.Exec(`DELETE FROM sessions WHERE user_id = ? AND token NOT IN (SELECT s2.token FROM sessions s2 WHERE s2.user_id = ? ORDER BY s2.created_at DESC LIMIT 4)`, userID, userID).Error; err != nil {
logrus.Error(err)
@@ -34,7 +34,7 @@ func CreateSession(userID UserID, realIP, userAgent string) (Session, error) {
session := Session{
Token: utils.GenerateToken32(),
UserID: userID,
- ClientIP: realIP,
+ ClientIP: "",
UserAgent: userAgent,
ExpiresAt: time.Now().Add(time.Duration(utils.OneMonthSecs) * time.Second),
}
diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go
@@ -336,7 +336,7 @@ func loginHandler(c echo.Context) error {
return actualLogin(data.Username, password, c.RealIP(), captchaSolved)
}
-func completeLogin(c echo.Context, user database.User, ip string) error {
+func completeLogin(c echo.Context, user database.User) error {
user.LoginAttempts = 0
_ = user.Save()
@@ -345,7 +345,7 @@ func completeLogin(c echo.Context, user database.User, ip string) error {
database.CreateSessionNotification(msg, session.Token)
}
- session, err := database.CreateSession(user.ID, ip, c.Request().UserAgent())
+ session, err := database.CreateSession(user.ID, c.Request().UserAgent())
if err != nil {
logrus.Error("Failed to create session : ", err)
}
@@ -482,7 +482,7 @@ func SessionsGpgSignTwoFactorHandler(c echo.Context) error {
return c.Redirect(http.StatusFound, redirectURL)
}
- return completeLogin(c, user, c.RealIP())
+ return completeLogin(c, user)
}
// SessionsTwoFactorHandler ...