public async Task AccountResetPasswordPostNormallyResetsPassword()
 {
     this.userManagerMock.Setup(mock => mock.ResetPasswordAsyncWrap(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult(IdentityResult.Success));
     this.accountController.UserManager = this.userManagerMock.Object;
     var model = new ResetPasswordViewModel { EmailAddress = RandomData.GetEmailAddress() };
     var result = await this.accountController.ResetPassword(model);
     result.Should().BeRedirectToRouteResult().WithAction("resetpasswordconfirmation");
     this.userManagerMock.Verify(m => m.ResetPasswordAsyncWrap(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>()), Times.Once);
 }
        public virtual async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return this.View(MVC.Account.Views.ResetPassword, model);
            }

            var user = await this.UserManager.FindByNameAsyncWrap(model.EmailAddress);
            if (user == null)
            {
                // Don't reveal that the user does not exist
                return this.RedirectToAction(MVC.Account.ResetPasswordConfirmation());
            }

            var result = await this.UserManager.ResetPasswordAsyncWrap(user.Id, model.Code, model.Password);
            if (result.Succeeded)
            {
                return this.RedirectToAction(MVC.Account.ResetPasswordConfirmation());
            }

            foreach (var errorMessage in result.Errors)
            {
                this.WebMessages.AddErrorMessage(errorMessage);
            }

            return this.View(MVC.Account.Views.ResetPassword, model);
        }
 public async Task AccountResetPasswordPostWrongEmailStillShowsConfirmWithoutReset()
 {
     this.userManagerMock.Setup(mock => mock.FindByNameAsyncWrap(It.IsAny<string>())).Returns(Task.FromResult<WebUser>(null));
     this.accountController.UserManager = this.userManagerMock.Object;
     var model = new ResetPasswordViewModel { EmailAddress = RandomData.GetEmailAddress() };
     var result = await this.accountController.ResetPassword(model);
     result.Should().BeRedirectToRouteResult().WithAction("resetpasswordconfirmation");
     this.userManagerMock.Verify(m => m.ResetPasswordAsyncWrap(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>()), Times.Never);
 }
        public virtual ActionResult ResetPassword(string code)
        {
            if (string.IsNullOrEmpty(code))
            {
                // TODO: Add to master data translations!
                this.WebMessages.AddErrorMessage(this.T("Invalid entry"), this.T("reset password can be invoked only from link, sent in e-mail."));
                return this.RedirectBack();
            }

            var model = new ResetPasswordViewModel { Code = code };
            return this.View(MVC.Account.Views.ResetPassword, model);
        }