Exemplo n.º 1
0
        public IActionResult RestorePassword(ModifyPasswordViewModel model)
        {
            if(!CheckRecaptcha(HttpContext.Request.Form["g-recaptcha-response"]))
            {
                ModelState.AddModelError("mail", "El Captcha no fue ingresado correctamente");
            }
            if (model.password != model.confirmPassword)
            {
                ModelState.AddModelError("password", "Las contraseñas no coinciden");
            }
            if (!ModelState.IsValid)
            {
                return View(new ModifyPasswordViewModel() { mail = model.mail });
            }
            try
            {
                api.ModifyPassword(model.mail, model.password);
                api.ModifyToken(model.mail);
            }
            catch (Exception e)
            {
                ModelState.AddModelError("password", e.Message);
                return View(new ModifyPasswordViewModel() { mail = model.mail });
            }
            return View("ModifiedCorrectly");

        }