From 812d5869d592e0395f663ed6623d8079c01240da Mon Sep 17 00:00:00 2001 From: AnnZhimol Date: Tue, 25 Apr 2023 09:35:46 +0400 Subject: [PATCH] =?UTF-8?q?=D1=8D=D1=82=D0=BE=D1=82=20=D0=BA=D0=BE=D0=BC?= =?UTF-8?q?=D0=BC=D0=B8=D1=82=20=D1=8D=D1=82=D0=BE=D1=82=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BC=D0=BC=D0=B8=D1=82=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SoftwareInstallationStoreApp/APIClient.cs | 11 +++++++++-- .../Controllers/HomeController.cs | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/SoftwareInstallation/SoftwareInstallationStoreApp/APIClient.cs b/SoftwareInstallation/SoftwareInstallationStoreApp/APIClient.cs index 2bd2819..e9129db 100644 --- a/SoftwareInstallation/SoftwareInstallationStoreApp/APIClient.cs +++ b/SoftwareInstallation/SoftwareInstallationStoreApp/APIClient.cs @@ -2,14 +2,16 @@ using Newtonsoft.Json; using System.Net.Http.Headers; using System.Text; +using SoftwareInstallationClientApp.Controllers; namespace SoftwareInstallationStoreApp { 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; + + private static string Password = string.Empty; + public static bool Access { get; private set; } public static void Connect(IConfiguration configuration) { @@ -33,6 +35,11 @@ namespace SoftwareInstallationStoreApp } } + public static void GetAccess(string password) + { + Access = Password.Equals(password); + } + public static void PostRequest(string requestUrl, T model) { var json = JsonConvert.SerializeObject(model); diff --git a/SoftwareInstallation/SoftwareInstallationStoreApp/Controllers/HomeController.cs b/SoftwareInstallation/SoftwareInstallationStoreApp/Controllers/HomeController.cs index b16bab3..0b53f3b 100644 --- a/SoftwareInstallation/SoftwareInstallationStoreApp/Controllers/HomeController.cs +++ b/SoftwareInstallation/SoftwareInstallationStoreApp/Controllers/HomeController.cs @@ -28,7 +28,7 @@ namespace SoftwareInstallationClientApp.Controllers { throw new Exception("Введите пароль"); } - APIClient.Access = password.Equals(APIClient.Password); + APIClient.GetAccess(password); if (APIClient.Access == false) { throw new Exception("Неправильный пароль");