This commit is contained in:
Павел Сорокин 2023-04-25 12:22:22 +04:00
parent c5031477e0
commit 98927033b2
2 changed files with 7 additions and 3 deletions

View File

@ -9,7 +9,7 @@ namespace ShipyardShopApp
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)
{
@ -18,6 +18,11 @@ namespace ShipyardShopApp
_client.DefaultRequestHeaders.Accept.Clear();
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
public static bool CheckPassword(string password)
{
APIClient.Access = password == Password;
return APIClient.Access;
}
public static T? GetRequest<T>(string requestUrl)
{

View File

@ -28,8 +28,7 @@ namespace ShipyardShopApp.Controllers
{
throw new Exception("password");
}
APIClient.Access = password.Equals(APIClient.Password);
if (APIClient.Access == false)
if (APIClient.CheckPassword(password))
{
throw new Exception("Не верный пароль");
}