Exemple #1
0
        public async Task ShouldBeReturnedAuthenticationResultWithFailedIfEmailNotRegistered()
        {
            var notExistingEmail = _faker.Person.Email;

            var authenticationResult = await _authenticationService.ResetPasswordAsync(notExistingEmail, "novasenha");

            authenticationResult.Should().BeOfType <AuthenticationResult>();
            authenticationResult.Success.Should().BeFalse();
            authenticationResult.Token.Should().BeNull();
            authenticationResult.Errors.Should().SatisfyRespectively(
                err => err.Should().Be("Email does not exist"));
        }
Exemple #2
0
        public async Task <IActionResult> ResetPassword([FromBody] AuthorResetPasswordRequest request)
        {
            var resetResponse = await _authService
                                .ResetPasswordAsync(request.Email, request.NewPassword)
                                .ConfigureAwait(false);

            if (!resetResponse.Success)
            {
                return(BadRequest(new AuthFailedResponse
                {
                    Errors = resetResponse.Errors
                }));
            }

            return(Ok(new ResetPasswordSuccessResponse
            {
                Reseted = true,
                SuccessMessage = "Senha redefinida com sucesso"
            }));
        }