feat: fix get clients ip

This commit is contained in:
2024-02-22 18:51:24 +01:00
parent cd42a6b0bf
commit 91585fdb0a
2 changed files with 8 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ package handler
import (
"fmt"
"log"
"gitea.urkob.com/urko/prosody-password/internal/services/fail2ban"
"gitea.urkob.com/urko/prosody-password/internal/services/prosody"
@@ -31,12 +32,13 @@ func (handler ProsodyHandler) Post(c *fiber.Ctx) error {
if err := c.BodyParser(&req); err != nil {
return RenderError(c, fmt.Errorf(" c.BodyParser(&req): %w", err), defaultErrMessage)
}
log.Println("request ip", c.IP())
req.CurrentPassword = c.FormValue("current_password")
req.NewPassword = c.FormValue("new_password")
if err := handler.prosodyService.ChangePassword(req.User, req.CurrentPassword, req.NewPassword); err != nil {
// for _, ip := range c.IPs() {
// handler.fail2banSrv.FailedAttempt(ip)
// }
for _, ip := range c.IPs() {
handler.fail2banSrv.FailedAttempt(ip)
}
return RenderError(c, fmt.Errorf("ChangePassword: %w", err), defaultErrMessage)
}