Tsukanova_I.V. LabWork06_hard #14

Closed
Inohara wants to merge 21 commits from LabWork06_hard into LabWork05_hard
2 changed files with 10 additions and 5 deletions
Showing only changes of commit 7a27aad092 - Show all commits

View File

@ -7,9 +7,8 @@ namespace IceCreamShopApp
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;
public static string Password = string.Empty;
public static bool Access { get; private set; }
public static void Connect(IConfiguration configuration)
{
Password = configuration["PasswordShop"];
@ -45,5 +44,10 @@ namespace IceCreamShopApp
throw new Exception(result);
}
}
public static void GetAccess(string password)
{
Access = Password == password;
}
}
}

View File

@ -27,8 +27,9 @@ namespace IceCreamShopApp.Controllers
{
throw new Exception("Введите пароль");
}
APIClient.Access = password.Equals(APIClient.Password);
if (APIClient.Access == false)
APIClient.GetAccess(password);
if (APIClient.Access == false)
{
throw new Exception("Неправильный пароль");
}