public ActionResult ForgotPassword(ForgotPassword model) { if (ModelState.IsValid) return _userRepository.AuthenticateUserSecurityAnswer(model, "ForgotPassword"); model.SecurityQuestions = _userRepository.GetSecurityQuestions(); return View(model); }
public ActionResult AuthenticateUserSecurityAnswer(ForgotPassword model, string view) { var user = _userStore.UserManager.FindByName(model.UserName); model.SecurityQuestions = _securityQuestionRepository.GetAll(); if (user == null) { ModelState.AddModelError("User authentication", "User authentication failed. Please enter correct user name"); return View(view, model); } int questionId; int.TryParse(model.SecurityQuestionId, out questionId); var userAuthentication = user.SecurityQuestionId == questionId && user.SecurityAnswer == model.Answer; if (userAuthentication) { var changePassword = new ResetPassword { UserName = Helper.Encrypt(model.UserName) }; return RedirectToAction("ResetPassword", changePassword); } ModelState.AddModelError("User authentication", "User authentication failed. Please enter correct answer"); return View(view, model); }
public ActionResult ForgotPassword() { var model = new ForgotPassword { SecurityQuestions = _userRepository.GetSecurityQuestions() }; return View(model); }
public ActionResult AuthenticateUserSecurityAnswer(ForgotPassword model, string view) { return _userRepository.AuthenticateUserSecurityAnswer(model, view); }