* Added Authentication
This commit is contained in:
@@ -8,6 +8,12 @@ public class UserService(HttpClient httpClient)
|
||||
{
|
||||
return await httpClient.GetFromJsonAsync<IEnumerable<UserDto>>("api/Users");
|
||||
}
|
||||
|
||||
public async Task<UserDto?> AuthenticateUserAsync(string login, string password)
|
||||
{
|
||||
var response = await httpClient.PostAsJsonAsync("api/users/authenticate", new { Login = login, Password = password });
|
||||
return response.IsSuccessStatusCode ? await response.Content.ReadFromJsonAsync<UserDto>() : null;
|
||||
}
|
||||
|
||||
public async Task<UserDto?> GetUserAsync(Guid userId)
|
||||
{
|
||||
@@ -19,9 +25,9 @@ public class UserService(HttpClient httpClient)
|
||||
return await httpClient.GetFromJsonAsync<UserDto>($"api/Users/by-username/?username={username}");
|
||||
}
|
||||
|
||||
public async Task AddUserAsync(UserDto user)
|
||||
public async Task<HttpResponseMessage> AddUserAsync(UserDto user)
|
||||
{
|
||||
await httpClient.PostAsJsonAsync("api/Users", user);
|
||||
return await httpClient.PostAsJsonAsync("api/Users", user);
|
||||
}
|
||||
|
||||
public async Task UpdateUserAsync(UserDto user)
|
||||
|
||||
Reference in New Issue
Block a user