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"); }
public IActionResult RestorePassword(ModifyPasswordViewModel model) { if (model.password != model.confirmPassword) { return(StatusCode(400, "Las contraseñas no coinciden")); } if (!ModelState.IsValid) { return(StatusCode(400)); } try { api.ModifyPassword(model.mail, model.password); } catch (Exception e) { return(StatusCode(400, e.Message)); } return(StatusCode(200, "Password modified correctly")); }