This commit is contained in:
@@ -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)
|
||||
{
|
||||
@@ -131,7 +130,7 @@ namespace AyaNovaQBI
|
||||
var tfaResponse = await TryPostAsync("auth/tfa-authenticate", tfaCreds.ToString(Newtonsoft.Json.Formatting.None));//trypost is no delay
|
||||
if (ProcessLoginResponse(tfaResponse)) return true;
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!ex.Message.Contains("2003"))//if not an authentication error (bad pin) then throw it back up for display
|
||||
throw ex;
|
||||
@@ -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;
|
||||
@@ -159,7 +177,7 @@ namespace AyaNovaQBI
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(a.ObjectResponse["data"]["l"].Value<bool>())//license lockout
|
||||
if (a.ObjectResponse["data"]["l"].Value<bool>())//license lockout
|
||||
{
|
||||
throw new Exception("Server login from QBI is disabled due to AyaNova license issue");
|
||||
}
|
||||
@@ -463,11 +481,15 @@ namespace AyaNovaQBI
|
||||
|
||||
//Get license
|
||||
var r = await GetAsync("license");
|
||||
ALicense = r.ObjectResponse["data"]["license"].ToObject < AyaNovaLicense>();
|
||||
ALicense = r.ObjectResponse["data"]["license"].ToObject<AyaNovaLicense>();
|
||||
|
||||
|
||||
//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?
|
||||
|
||||
Reference in New Issue
Block a user