From afb90c1b5f819f6eeab33959e3ca1a7c9f09911c Mon Sep 17 00:00:00 2001 From: dasha Date: Tue, 25 Apr 2023 14:04:11 +0400 Subject: [PATCH] fix --- SushiBar/SushiBarShopApp/APIClient.cs | 7 ++++++- SushiBar/SushiBarShopApp/Controllers/HomeController.cs | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/SushiBar/SushiBarShopApp/APIClient.cs b/SushiBar/SushiBarShopApp/APIClient.cs index c1e1f10..b9113eb 100644 --- a/SushiBar/SushiBarShopApp/APIClient.cs +++ b/SushiBar/SushiBarShopApp/APIClient.cs @@ -9,7 +9,7 @@ namespace SushiBarShopApp { 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) { @@ -19,6 +19,11 @@ namespace SushiBarShopApp _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); } + public static bool CheckPassword(string password) + { + return APIClient.Access = password == Password; + } + public static T? GetRequest(string requestUrl) { var response = _client.GetAsync(requestUrl); diff --git a/SushiBar/SushiBarShopApp/Controllers/HomeController.cs b/SushiBar/SushiBarShopApp/Controllers/HomeController.cs index 0737069..2d02e75 100644 --- a/SushiBar/SushiBarShopApp/Controllers/HomeController.cs +++ b/SushiBar/SushiBarShopApp/Controllers/HomeController.cs @@ -28,8 +28,7 @@ namespace SushiBarShopApp.Controllers { throw new Exception("Введите пароль"); } - APIClient.Access = password.Equals(APIClient.Password); - if (APIClient.Access == false) + if (!APIClient.CheckPassword(password)) { throw new Exception("Неправильный пароль"); }