From 0ff4abc04a15df811710088065ba25afab988518 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Tue, 25 Apr 2023 12:59:54 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B0=D0=BD=D0=BD=D0=B0=D1=8F=20La?= =?UTF-8?q?bWork05=5FHard.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BlacksmithWorkshopShopApp/APIClient.cs | 10 ++++++++-- .../Controllers/HomeController.cs | 6 ++---- 2 files changed, 10 insertions(+), 6 deletions(-) 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("Неверный пароль"); }