public async Task <IActionResult> Index(InputModelLogin model) { _model = model; if (ModelState.IsValid) { var result = await _user.UserLoginAsync(model); if (result.Succeeded) { return(Redirect("/Principal/Principal")); } else { _model.ErrorMessage = "Correo o contraseña inválidos."; return(Redirect("/")); } } else { foreach (var modelState in ModelState.Values) { foreach (var error in modelState.Errors) { _model.ErrorMessage = error.ErrorMessage; } } return(Redirect("/")); } }