public JsonResult RecoverUserName(RecoverPasswordViewModel vm) { if (WebSecurity.UserExists(vm.DisplayName)) return Json(true, JsonRequestBehavior.AllowGet); string noUser = String.Format(CultureInfo.InvariantCulture, "The user name {0} could not be found in database. Are you sure you entered the correct user name?", vm.DisplayName); return Json(noUser, JsonRequestBehavior.AllowGet); }
public ActionResult ForgotPassword(RecoverPasswordViewModel vm) { if (ModelState.IsValid) { //check user existance var user = Membership.GetUser(vm.DisplayName); if (user == null) { ViewBag.toast = "<script> $(document).ready(function () {" + "toastr.options = { 'positionClass': 'toast-bottom-right' };" + "toastr.error('User name not found. Pleas ensure user name is correct.');});</script>"; return View(vm); } else CreateAndEmailVerificationToken(vm.DisplayName); TempData["toast"] = "<script> $(document).ready(function () {" + "toastr.options = { 'positionClass': 'toast-bottom-right' };" + "toastr.success('Your password was successfully changed!');});</script>"; return View("SentPassword"); } return View(vm); }