Files
blazor-server-mini-sandbox/App.Services/AuthService/AuthService.cs
2026-01-28 22:39:29 +01:00

33 lines
1.3 KiB
C#

using Microsoft.AspNetCore.Components.Authorization;
using Sandbox.Models.ViewModels;
namespace Sandbox.App.Services.AuthService;
public class AuthService(HttpClient httpClient, AuthenticationStateProvider authenticationStateProvider)
: IAuthService
{
private readonly AuthenticationStateProvider _authenticationStateProvider = authenticationStateProvider;
public async Task<ServiceResponse<int>> Register(UserRegister request)
{
var result = await httpClient.PostAsJsonAsync("api/auth/register", request);
return await result.Content.ReadFromJsonAsync<ServiceResponse<int>>();
}
// public async Task<ServiceResponse<string>> Login(UserLogin request)
// {
// var result = await _http.PostAsJsonAsync("api/auth/login", request);
// return await result.Content.ReadFromJsonAsync<ServiceResponse<string>>();
// }
//
// public async Task<ServiceResponse<bool>> ChangePassword(UserChangePassword request)
// {
// var result = await _http.PostAsJsonAsync("api/auth/change-password", request.Password);
// return await result.Content.ReadFromJsonAsync<ServiceResponse<bool>>();
// }
// public async Task<bool> IsUserAuthenticated()
// {
// return (await _authenticationStateProvider.GetAuthenticationStateAsync()).User.Identity.IsAuthenticated;
// }
}