예제 #1
0
		public string SetResetPasswordSession(PasswordRecoveryViewModel model)
		{
			if (model == null)
				throw new ArgumentNullException("model");
			var sessionId = _usersManagement.SetResetPasswordSession(model.Email);

			return sessionId;
		}
예제 #2
0
		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);
		}
예제 #3
0
		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>();
		}
예제 #4
0
파일: MailManager.cs 프로젝트: evkap/DVS
		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);
		}
예제 #5
0
		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);
		}
예제 #6
0
		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);
		}
예제 #7
0
		private void SendResetPasswordEmail()
		{
			var model = new PasswordRecoveryViewModel()
			{
				ChangePasswordUrl = GetParamValue(TaskParamsKey.ResetPasswordUrl),
				Email = GetEmailByUserId()
			};
			_mailManager.SendResetPasswordMail(model);
		}