From 98927033b2ef56d8666a8fef775e363f70eced61 Mon Sep 17 00:00:00 2001 From: Pavel_Sorokin Date: Tue, 25 Apr 2023 12:22:22 +0400 Subject: [PATCH] fix --- Shipyard/ShipyardShopApp/APIClient.cs | 7 ++++++- Shipyard/ShipyardShopApp/Controllers/HomeController.cs | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Shipyard/ShipyardShopApp/APIClient.cs b/Shipyard/ShipyardShopApp/APIClient.cs index 3c7f9e9..1ca9fdc 100644 --- a/Shipyard/ShipyardShopApp/APIClient.cs +++ b/Shipyard/ShipyardShopApp/APIClient.cs @@ -9,7 +9,7 @@ namespace ShipyardShopApp private static readonly HttpClient _client = new(); public static string Password { get; private set; } = string.Empty; - public static bool Access { get; set; } = false; + public static bool Access { get; private set; } = false; public static void Connect(IConfiguration configuration) { @@ -18,6 +18,11 @@ namespace ShipyardShopApp _client.DefaultRequestHeaders.Accept.Clear(); _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); } + public static bool CheckPassword(string password) + { + APIClient.Access = password == Password; + return APIClient.Access; + } public static T? GetRequest(string requestUrl) { diff --git a/Shipyard/ShipyardShopApp/Controllers/HomeController.cs b/Shipyard/ShipyardShopApp/Controllers/HomeController.cs index e7bc1c8..3491688 100644 --- a/Shipyard/ShipyardShopApp/Controllers/HomeController.cs +++ b/Shipyard/ShipyardShopApp/Controllers/HomeController.cs @@ -28,8 +28,7 @@ namespace ShipyardShopApp.Controllers { throw new Exception("password"); } - APIClient.Access = password.Equals(APIClient.Password); - if (APIClient.Access == false) + if (APIClient.CheckPassword(password)) { throw new Exception("Не верный пароль"); }