public async Task GetJwtToken_UserNotFound_ReturnsNull() { // Arrange var model = new LoginModel { Email = "*****@*****.**", Password = "******" }; _userManager.FindByEmailAsync(model.Email).Returns(Task.FromResult <JobApplicationUser>(null)); // Act var result = await _accountManagerService.GetJwtToken(model).ConfigureAwait(false); // Assert Assert.Null(result); }
public async Task <IActionResult> GetToken([FromBody] LoginModel model) { try { var jwtResponse = await _accountManagerService.GetJwtToken(model).ConfigureAwait(false); if (string.IsNullOrEmpty(jwtResponse)) { return(BadRequest("Failed to Login")); } return(Ok(jwtResponse)); } catch (Exception e) { _logger.LogError(LoggingEvents.Auth, e, $"Exception when trying to login"); return(BadRequest(e)); } }