Compare commits

..

2 Commits

Author SHA1 Message Date
7af2852f05 Merge branch 'LabWork05Hard' into LabWork06Hard 2023-04-25 14:05:48 +04:00
afb90c1b5f fix 2023-04-25 14:04:11 +04:00
2 changed files with 7 additions and 3 deletions

View File

@ -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<T>(string requestUrl)
{
var response = _client.GetAsync(requestUrl);

View File

@ -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("Неправильный пароль");
}