public ActionResult Login(MemberLoginModel viewModel) { try { var googleRecaptcha = new Models.GoogleReCaptchaValidator(Request); if (!googleRecaptcha.ValidateRequest()) { throw new Exception("Please fill out the reCAPTCHA"); } if (ModelState.IsValid) { if (viewModel.Login()) { return(RedirectToAction("Index", "Home")); } else { throw new Exception("Invalid username or password"); } } } catch (Exception ex) { while (ex != null) { ModelState.AddModelError("", ex.Message); ex = ex.InnerException; } } return(View()); }
public ActionResult Create(NewMemberModel viewModel) { try { var googleRecaptcha = new Models.GoogleReCaptchaValidator(Request); if (!googleRecaptcha.ValidateRequest()) { throw new Exception("Please fill out the reCAPTCHA"); } if (ModelState.IsValid) { viewModel.CreateMember(); return(RedirectToAction("AccountCreated")); } } catch (Exception ex) { while (ex != null) { ModelState.AddModelError("", ex.Message); ex = ex.InnerException; } } return(View()); }