mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-04-20 20:03:39 +03:00
add login logging for banning brute force attacks
This commit is contained in:
parent
2fdafd34ca
commit
8b75583a04
1 changed files with 3 additions and 1 deletions
|
@ -75,7 +75,7 @@ func Login(db store.IStore) echo.HandlerFunc {
|
||||||
|
|
||||||
dbuser, err := db.GetUserByName(username)
|
dbuser, err := db.GetUserByName(username)
|
||||||
if err != nil {
|
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"})
|
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Invalid credentials"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,9 +130,11 @@ func Login(db store.IStore) echo.HandlerFunc {
|
||||||
cookie.SameSite = http.SameSiteLaxMode
|
cookie.SameSite = http.SameSiteLaxMode
|
||||||
c.SetCookie(cookie)
|
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"})
|
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"})
|
return c.JSON(http.StatusUnauthorized, jsonHTTPResponse{false, "Invalid credentials"})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue