using Newtonsoft.Json; using WorkFlowCheck.Common.DTO; using WorkFlowCheck.Web.Services.Interfaces; namespace WorkFlowCheck.Web.Services { public class UserService : BaseService, IUserService { public UserService(HttpClient httpClient, IConfiguration configuration, IHttpContextAccessor httpContextAccessor) : base(httpClient, configuration, httpContextAccessor) { } public async Task> Authenticate(string username, string password) { try { // Az API végpont meghatározása string endpoint = $"{_httpClient.BaseAddress}api/user/authenticate"; var userDTO = new UserDTO() { Email = "", FirstName = "", LastName = "", Id = 0, UserName = username, Password = password, JwtToken = "", RoleDTO = new List(), }; // HTTP POST kérés küldése using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, userDTO)) { httpResponseMessage.EnsureSuccessStatusCode(); var jsonString = await httpResponseMessage.Content.ReadAsStringAsync(); var response = JsonConvert.DeserializeObject>(jsonString); return response ?? new ApiResponseDTO { IsSuccess = false, }; } } catch (Exception ex) { // Hiba visszaadása return new ApiResponseDTO { IsSuccess = false }; } } } }