This commit is contained in:
2022-06-22 18:04:31 +00:00
parent 4102809635
commit b14b36c6e9

View File

@@ -104,11 +104,10 @@ namespace AyaNovaQBI
throw new Exception("Authentication error, route: AUTH\r\nError:" + Err + "\r\nInner error:" + InnerErr);
}
//ApiResponse a = await PostAsync("auth", creds.ToString());
var a = new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(await response.Content.ReadAsStringAsync()) };
if (response.IsSuccessStatusCode)
{
var a = new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(await response.Content.ReadAsStringAsync()) };
bool tfa = a.ObjectResponse["data"]["tfa"].Value<bool>();
if (tfa == true)
{
@@ -148,10 +147,29 @@ namespace AyaNovaQBI
return ProcessLoginResponse(a);
}
}
else
{
/*
"error": {
"code": "2001",
"message": "\"E1020 - License key expired 2022-06-20 5:00 PM\r\nLogin as SuperUser to start evaluation / install license\""
}
*/
if (a.ObjectResponse != null && a.ObjectResponse.ContainsKey("error"))
{
var errCode = a.ObjectResponse["error"]["code"].Value<string>();
if (errCode.Contains("2003")) return false;//simple authentication error
var errMessage = a.ObjectResponse["error"]["message"].Value<string>();
throw new Exception($"Code: {errCode} - {errMessage}");
}
return false;
}
}
private static bool ProcessLoginResponse(ApiResponse a)
{
if (a.ObjectResponse == null) return false;
@@ -467,7 +485,11 @@ namespace AyaNovaQBI
//UNEXPIRED AYANOVA LICENSE?
todo check this
if (ALicense.licenseWillExpire && ALicense.licenseExpiration < DateTime.UtcNow)
{
initErrors.AppendLine($"AyaNova license has expired {ALicense.licenseExpiration.ToLocalTime().ToString("g")}");
return false;
}
//QBI LICENSED?