using Microsoft.AspNetCore.Components; namespace Hcs.WebApp.Services { public class IdentityService(NavigationManager navigationManager, IHttpClientFactory factory) { private readonly Uri baseUri = new($"{navigationManager.BaseUri}identity/"); private readonly HttpClient httpClient = factory.CreateClient("WithIdentity"); public async Task ChangePassword(string oldPassword, string newPassword) { var uri = new Uri($"{baseUri}change-password"); var content = new FormUrlEncodedContent(new Dictionary { { "oldPassword", oldPassword }, { "newPassword", newPassword } }); var response = await httpClient.PostAsync(uri, content); if (!response.IsSuccessStatusCode) { var message = await response.Content.ReadAsStringAsync(); throw new ApplicationException(message); } } } }