From ee99e819915710e3ab7cb6d5da8ec462c6854720 Mon Sep 17 00:00:00 2001 From: Urko Date: Fri, 4 Aug 2023 23:15:22 +0200 Subject: [PATCH] fix req body parser --- internal/api/handler/prosody_hdl.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/api/handler/prosody_hdl.go b/internal/api/handler/prosody_hdl.go index 7c30a73..96762a3 100644 --- a/internal/api/handler/prosody_hdl.go +++ b/internal/api/handler/prosody_hdl.go @@ -29,11 +29,15 @@ type changePasswordReq struct { func (handler ProsodyHandler) Post(c *fiber.Ctx) error { log.Println("body", string(c.Body())) - req := changePasswordReq{ - CurrentPassword: c.FormValue("current_password", ""), - NewPassword: c.FormValue("new_password", ""), - User: c.FormValue("user", ""), + req := changePasswordReq{} + if err := c.BodyParser(&req); err != nil { + return RenderError(c, fmt.Errorf(" c.BodyParser(&req): %w", err), defaultErrMessage) } + // req := changePasswordReq{ + // CurrentPassword: c.FormValue("current_password", ""), + // NewPassword: c.FormValue("new_password", ""), + // User: c.FormValue("user", ""), + // } if err := handler.prosodyService.ChangePassword(req.User, req.CurrentPassword, req.NewPassword); err != nil { // for _, ip := range c.IPs() { // handler.fail2banSrv.FailedAttempt(ip)