diff --git a/BlacksmithWorkshop/BlacksmithWorkshopShopApp/APIClient.cs b/BlacksmithWorkshop/BlacksmithWorkshopShopApp/APIClient.cs index 96beaa2..e7677e1 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopShopApp/APIClient.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopShopApp/APIClient.cs @@ -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(string requestUrl) + public static bool CheckPassword(string password) + { + APIClient.InSystem = password == Password; + return APIClient.InSystem; + } + + public static T? GetRequest(string requestUrl) { var response = _client.GetAsync(requestUrl); var result = response.Result.Content.ReadAsStringAsync().Result; diff --git a/BlacksmithWorkshop/BlacksmithWorkshopShopApp/Controllers/HomeController.cs b/BlacksmithWorkshop/BlacksmithWorkshopShopApp/Controllers/HomeController.cs index ac8fec7..75d7067 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopShopApp/Controllers/HomeController.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopShopApp/Controllers/HomeController.cs @@ -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("Неверный пароль"); }