public async Task <bool> CheckDirectLineUserIsAuthenticated(string userName) { var urlService = WebConfigurationManager.AppSettings["authRestServiceUrl"]; HttpClient client = new HttpClient { BaseAddress = new Uri(urlService) }; var directLineUserDto = new DirectLineUserDto(); directLineUserDto.UserName = userName; StringContent content = new StringContent(JsonConvert.SerializeObject(directLineUserDto), Encoding.UTF8, ContentType.Json); var checkUserAccessTokenRequest = await client.PostAsync(checkDirectLineUserEndpoint, content); var checkUserAccessTokenResponse = await checkUserAccessTokenRequest.Content.ReadAsStringAsync(); if (checkUserAccessTokenResponse == "true") { return(true); } else { return(false); } }
public async Task <bool> CheckUserIsLogged([FromBody] DirectLineUserDto directLineUserDto) { var directLineLogin = _context.DirectLineLogins.Where(directLineLoginUser => directLineLoginUser.UserName == directLineUserDto.UserName && directLineLoginUser.ExpirationTime > DateTime.UtcNow).FirstOrDefault(); if (directLineLogin == null) { return(false); } return(true); }