public string SetResetPasswordSession(PasswordRecoveryViewModel model) { if (model == null) throw new ArgumentNullException("model"); var sessionId = _usersManagement.SetResetPasswordSession(model.Email); return sessionId; }
public void SetResetPasswordSession_should_return_session_id_if_model_is_correct() { var model = new PasswordRecoveryViewModel(); _usersManagement.SetResetPasswordSession(Arg.Any<String>()).Returns(_sessionId); var result = _resetPasswordService.SetResetPasswordSession(model); result.Should().NotBeNullOrEmpty().And.Be(_sessionId); }
public void PasswordRecovery_post_action_should_return_password_recovery_view_if_model_state_is_not_valid() { _target.ModelState.AddModelError("test", "test"); var model = new PasswordRecoveryViewModel(); var result = _target.PasswordRecovery(model); result.Should().NotBeNull().And.BeOfType<ViewResult>(); ((ViewResult)result).ViewData.Model.Should().BeOfType<PasswordRecoveryViewModel>(); }
public void SendResetPasswordMail(PasswordRecoveryViewModel model) { var user = _userManagement.GetByEmail(model.Email); Dictionary<string, string> replaceDictionary = new Dictionary<string, string>(); replaceDictionary.Add(Constants.EmailTemplateKeyWords.UserFirstName, user.FirstName); replaceDictionary.Add(Constants.EmailTemplateKeyWords.UserLastName, user.LastName); replaceDictionary.Add(Constants.EmailTemplateKeyWords.PasswordResetURL, model.ChangePasswordUrl); SendMailInternal(EmailTemplateType.PasswordRecovery, user.Email, replaceDictionary); }
public ActionResult PasswordRecovery(PasswordRecoveryViewModel model) { if (ModelState.IsValid) { var sessionId = _resetPasswordService.SetResetPasswordSession(model); CommitProviderInstance.Commit(); var urlHelper = new UrlHelper(this.Request.RequestContext); model.ChangePasswordUrl = urlHelper.AbsoluteAction(NameHelper.ResetPassword.ChangePassword, NameHelper.ResetPassword.Controller, new { area = "", sessionId = sessionId }); _taskManager.ScheduleResetPasswordNotification(model.Email, model.ChangePasswordUrl); ViewBag.ShowCofirmation = true; } return View(model); }
public void MailManagerTest_SendResetPasswordMail() { _usersManagement.GetByEmail(Arg.Any<string>()).Returns(new User() { FirstName = "first name", LastName = "last name", Email = "*****@*****.**" }); var viewModel = new PasswordRecoveryViewModel() { ChangePasswordUrl = "ChangePasswordUrl", Email = "*****@*****.**" }; _target.SendResetPasswordMail(viewModel); }
private void SendResetPasswordEmail() { var model = new PasswordRecoveryViewModel() { ChangePasswordUrl = GetParamValue(TaskParamsKey.ResetPasswordUrl), Email = GetEmailByUserId() }; _mailManager.SendResetPasswordMail(model); }