Merge pull request #2 from rwillert/login-logging

add login logging for banning brute force attacks
This commit is contained in:
Robert Willert 2024-12-17 18:21:37 +01:00 committed by GitHub
commit ec416c90c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -75,7 +75,7 @@ func Login(db store.IStore) echo.HandlerFunc {
dbuser, err := db.GetUserByName(username)
if err != nil {
log.Infof("Cannot query user %s from DB", username)
log.Warnf("Invalid credentials. Cannot query user %s from DB (%s)", username, c.Request().RemoteAddr)
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Invalid credentials"})
}
@ -130,9 +130,11 @@ func Login(db store.IStore) echo.HandlerFunc {
cookie.SameSite = http.SameSiteLaxMode
c.SetCookie(cookie)
log.Infof("Logged in successfully user %s (%s)", username, c.Request().RemoteAddr)
return c.JSON(http.StatusOK, jsonHTTPResponse{true, "Logged in successfully"})
}
log.Warnf("Invalid credentials user %s (%s)", username, c.Request().RemoteAddr)
return c.JSON(http.StatusUnauthorized, jsonHTTPResponse{false, "Invalid credentials"})
}
}