This commit is contained in:
2020-04-27 22:34:07 +00:00
parent 20c174603c
commit 0fcc7772f3

View File

@@ -29,6 +29,8 @@ namespace AyaNova.PlugIn.V8
JWT = string.Empty; JWT = string.Empty;
} }
#region INIT / AUTH
private static void InitClient() private static void InitClient()
{ {
if (Initialized) return; if (Initialized) return;
@@ -90,28 +92,28 @@ namespace AyaNova.PlugIn.V8
public async static Task<bool> AuthenticateAsync(string login, string password = null) public async static Task<bool> AuthenticateAsync(string login, string password = null)
{ {
InitClient(); InitClient();
if (password == null) if (password == null)
password = login; password = login;
dynamic creds = new JObject();
creds.login = login;
creds.password = password;
ApiResponse a = await PostAsync("Auth", creds.ToString()); dynamic creds = new JObject();
creds.login = login;
creds.password = password;
if (a.HttpResponse.IsSuccessStatusCode) ApiResponse a = await PostAsync("Auth", creds.ToString());
{
JWT=a.ObjectResponse["data"]["token"].Value<string>(); if (a.HttpResponse.IsSuccessStatusCode)
return true; {
} JWT = a.ObjectResponse["data"]["token"].Value<string>();
return true;
}
return false; return false;
} }
@@ -179,6 +181,7 @@ namespace AyaNova.PlugIn.V8
} }
return JObject.Parse(jsonString); return JObject.Parse(jsonString);
} }
#endregion
}//eoc }//eoc