fix req body parser

This commit is contained in:
Urko 2023-08-04 23:15:22 +02:00
parent 39977f68f0
commit ee99e81991
1 changed files with 8 additions and 4 deletions

View File

@ -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)