Merge branch 'LabWork05Hard' into LabWork06Hard
This commit is contained in:
commit
7af2852f05
@ -9,7 +9,7 @@ namespace SushiBarShopApp
|
|||||||
{
|
{
|
||||||
private static readonly HttpClient _client = new();
|
private static readonly HttpClient _client = new();
|
||||||
public static string Password { get; private set; } = string.Empty;
|
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)
|
public static void Connect(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
@ -19,6 +19,11 @@ namespace SushiBarShopApp
|
|||||||
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
_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)
|
public static T? GetRequest<T>(string requestUrl)
|
||||||
{
|
{
|
||||||
var response = _client.GetAsync(requestUrl);
|
var response = _client.GetAsync(requestUrl);
|
||||||
|
@ -28,8 +28,7 @@ namespace SushiBarShopApp.Controllers
|
|||||||
{
|
{
|
||||||
throw new Exception("Введите пароль");
|
throw new Exception("Введите пароль");
|
||||||
}
|
}
|
||||||
APIClient.Access = password.Equals(APIClient.Password);
|
if (!APIClient.CheckPassword(password))
|
||||||
if (APIClient.Access == false)
|
|
||||||
{
|
{
|
||||||
throw new Exception("Неправильный пароль");
|
throw new Exception("Неправильный пароль");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user