From 165a765693fe23f5d32ab703424779b15ce9d80c Mon Sep 17 00:00:00 2001 From: Inohara Date: Tue, 25 Apr 2023 09:48:29 +0400 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=B4=D0=B0=D0=BD=D0=B0=205=20=D1=83?= =?UTF-8?q?=D1=81=D0=BB=D0=BE=D0=B6=D0=BD=D0=B5=D0=BD=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IceCreamShop/IceCreamShopApp/APIClient.cs | 10 +++++++--- .../IceCreamShopApp/Controllers/HomeController.cs | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/IceCreamShop/IceCreamShopApp/APIClient.cs b/IceCreamShop/IceCreamShopApp/APIClient.cs index 0a5fb92..ba5c372 100644 --- a/IceCreamShop/IceCreamShopApp/APIClient.cs +++ b/IceCreamShop/IceCreamShopApp/APIClient.cs @@ -7,9 +7,8 @@ namespace IceCreamShopApp public class APIClient { private static readonly HttpClient _client = new(); - public static string Password { get; private set; } = string.Empty; - public static bool Access { get; set; } = false; - + public static string Password = string.Empty; + public static bool Access { get; private set; } public static void Connect(IConfiguration configuration) { Password = configuration["PasswordShop"]; @@ -45,5 +44,10 @@ namespace IceCreamShopApp throw new Exception(result); } } + + public static void GetAccess(string password) + { + Access = Password == password; + } } } diff --git a/IceCreamShop/IceCreamShopApp/Controllers/HomeController.cs b/IceCreamShop/IceCreamShopApp/Controllers/HomeController.cs index 06c893a..730cab4 100644 --- a/IceCreamShop/IceCreamShopApp/Controllers/HomeController.cs +++ b/IceCreamShop/IceCreamShopApp/Controllers/HomeController.cs @@ -27,8 +27,9 @@ namespace IceCreamShopApp.Controllers { throw new Exception("Введите пароль"); } - APIClient.Access = password.Equals(APIClient.Password); - if (APIClient.Access == false) + APIClient.GetAccess(password); + + if (APIClient.Access == false) { throw new Exception("Неправильный пароль"); }