26 lines
997 B
C#
26 lines
997 B
C#
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 ChangePasswordAsync(string oldPassword, string newPassword)
|
|
{
|
|
var uri = new Uri($"{baseUri}change-password");
|
|
var content = new FormUrlEncodedContent(new Dictionary<string, string> {
|
|
{ "oldPassword", oldPassword },
|
|
{ "newPassword", newPassword }
|
|
});
|
|
var response = await httpClient.PostAsync(uri, content);
|
|
if (!response.IsSuccessStatusCode)
|
|
{
|
|
var message = await response.Content.ReadAsStringAsync();
|
|
throw new ApplicationException(message);
|
|
}
|
|
}
|
|
}
|
|
}
|