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

            var authenticationResult = await _authenticationService.LoginAsync(invalidEmail, _faker.Internet.Password());

            authenticationResult.Should().BeOfType <AuthenticationResult>();
            authenticationResult.Success.Should().BeFalse();
            authenticationResult.Errors.Should().SatisfyRespectively(
                err => err.Should().Be("Author does not exist"));
        }
Exemple #2
0
        public async Task <IActionResult> Login([FromBody] AuthorLoginRequest request)
        {
            var authResponse = await _authService
                               .LoginAsync(request.Email, request.Password)
                               .ConfigureAwait(false);

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

            return(Ok(new AuthSuccessResponse
            {
                Token = authResponse.Token
            }));
        }