Сданная LabWork05_Hard.

This commit is contained in:
Programmist73 2023-04-25 12:59:54 +04:00
parent cba839f32a
commit 0ff4abc04a
2 changed files with 10 additions and 6 deletions

View File

@ -10,7 +10,7 @@ namespace BlacksmithWorkshopShopApp
public static string Password { get; private set; } = string.Empty;
public static bool InSystem { get; set; }
public static bool InSystem { get; private set; }
public static void Connect(IConfiguration configuration)
{
@ -20,7 +20,13 @@ namespace BlacksmithWorkshopShopApp
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
public static T? GetRequest<T>(string requestUrl)
public static bool CheckPassword(string password)
{
APIClient.InSystem = password == Password;
return APIClient.InSystem;
}
public static T? GetRequest<T>(string requestUrl)
{
var response = _client.GetAsync(requestUrl);
var result = response.Result.Content.ReadAsStringAsync().Result;

View File

@ -54,10 +54,8 @@ namespace BlacksmithWorkshopShopApp.Controllers
throw new Exception("Введите пароль");
}
APIClient.InSystem = APIClient.Password == password;
if (!APIClient.InSystem)
{
if (APIClient.CheckPassword(password))
{
throw new Exception("Неверный пароль");
}