Merge branch 'LabWork05Hard' into LabWork06Hard

This commit is contained in:
dasha 2023-04-25 14:05:48 +04:00
commit 7af2852f05
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("Неправильный пароль");
}