public async void ShouldReturnUserIdForValidCreds() { loginRepo.Setup(r => r.GetCredentialsAsync(It.IsAny <LoginCredentials>())) .ReturnsAsync(loginCredentials); var result = await processor.ValidateCredentialsAsync(loginCredentials); Assert.Equal <int>(loginCredentials.Id, result); }
public async Task <IActionResult> Authenticate([FromBody] LoginDto loginDto) { var loginCreds = mapper.Map <LoginCredentials>(loginDto); var userId = await authenticationProcessor.ValidateCredentialsAsync(loginCreds); if (userId == 0) { return(new UnauthorizedResult()); } var response = new AuthenticationResponseDto(userId); return(new OkObjectResult(response)); }