public async Task <IActionResult> Index(string email, string code)
        {
            if (User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(code))
            {
                return(RedirectToAction("Index", "Login"));
            }

            var hashIsValid = await passwordResetService.EmailAndResetPasswordHashAreValidAsync(
                email,
                code,
                ResetPasswordHelpers.ResetPasswordHashExpiryTime
                );

            TempData.Set(new ResetPasswordData(email, code));

            if (!hashIsValid)
            {
                return(RedirectToAction("Error"));
            }

            return(View(new ConfirmPasswordViewModel()));
        }
Example #2
0
        public async Task Index_should_render_if_user_is_unauthenticated_and_query_params_are_valid()
        {
            // Given
            A.CallTo(
                () => passwordResetService.EmailAndResetPasswordHashAreValidAsync(
                    "email",
                    "code",
                    ResetPasswordHelpers.ResetPasswordHashExpiryTime
                    )
                )
            .Returns(Task.FromResult(true));

            // When
            var result = await unauthenticatedController.Index("email", "code");

            // Then
            result.Should().BeViewResult().WithDefaultViewName();
        }