Validating the password and repeated password on register page

This commit is contained in:
Lilleman auf Larv 2022-04-26 13:51:40 +02:00
parent 96e884f0a2
commit ff747d7cc2

View File

@ -33,9 +33,18 @@ func (h Handlers) RegisterPost(c *fiber.Ctx) error {
err := c.BodyParser(newUser)
if err != nil {
h.Log.Debug("Invalid input data", "err", err.Error())
h.Log.Debug("Invalid input data, BodyParser() failed", "err", err.Error())
c.Status(400)
}
if newUser.Password != newUser.RepeatPassword {
h.Log.Debug("Password and RepeatPassword does not match")
c.Status(400)
return c.Status(400).SendString(views.Register(views.RegisterData{
ErrMsg: "Password and repeated password does not match!",
}))
}
newUser.Name = newUser.Username
newUser.Fields = append(newUser.Fields, field{
Name: "role",