This commit is contained in:
@@ -26,14 +26,14 @@ namespace AyaNovaQBI
|
|||||||
|
|
||||||
internal static string JWT { get; set; }
|
internal static string JWT { get; set; }
|
||||||
|
|
||||||
// internal static long AyaNovaUserId { get; set; } //probably don't need this, if I do then some code will need to be added to decode the JWT or at the server to get my currently logged in USER ID
|
// internal static long AyaNovaUserId { get; set; } //probably don't need this, if I do then some code will need to be added to decode the JWT or at the server to get my currently logged in USER ID
|
||||||
internal static string AyaNovaUserName { get; set; }
|
internal static string AyaNovaUserName { get; set; }
|
||||||
internal static AuthorizationRoles AyaNovaUserRoles { get; set; }
|
internal static AuthorizationRoles AyaNovaUserRoles { get; set; }
|
||||||
internal static UserType AyaNovaUserType { get; set; }
|
internal static UserType AyaNovaUserType { get; set; }
|
||||||
|
|
||||||
internal static AyaNovaLicense ALicense { get; set; } = null;
|
internal static AyaNovaLicense ALicense { get; set; } = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void InitClient()
|
public static void InitClient()
|
||||||
@@ -100,15 +100,14 @@ namespace AyaNovaQBI
|
|||||||
var InnerErr = "";
|
var InnerErr = "";
|
||||||
if (ex.InnerException != null)
|
if (ex.InnerException != null)
|
||||||
InnerErr = ex.InnerException.Message;
|
InnerErr = ex.InnerException.Message;
|
||||||
|
|
||||||
throw new Exception("Authentication error, route: AUTH\r\nError:" + Err + "\r\nInner error:" + InnerErr);
|
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)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
var a = new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(await response.Content.ReadAsStringAsync()) };
|
|
||||||
bool tfa = a.ObjectResponse["data"]["tfa"].Value<bool>();
|
bool tfa = a.ObjectResponse["data"]["tfa"].Value<bool>();
|
||||||
if (tfa == true)
|
if (tfa == true)
|
||||||
{
|
{
|
||||||
@@ -131,14 +130,14 @@ namespace AyaNovaQBI
|
|||||||
var tfaResponse = await TryPostAsync("auth/tfa-authenticate", tfaCreds.ToString(Newtonsoft.Json.Formatting.None));//trypost is no delay
|
var tfaResponse = await TryPostAsync("auth/tfa-authenticate", tfaCreds.ToString(Newtonsoft.Json.Formatting.None));//trypost is no delay
|
||||||
if (ProcessLoginResponse(tfaResponse)) return true;
|
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
|
if (!ex.Message.Contains("2003"))//if not an authentication error (bad pin) then throw it back up for display
|
||||||
throw ex;
|
throw ex;
|
||||||
//otherwise eat it and let them re-enter the pin again to mirror how ayanova web client works
|
//otherwise eat it and let them re-enter the pin again to mirror how ayanova web client works
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
||||||
@@ -148,8 +147,27 @@ namespace AyaNovaQBI
|
|||||||
return ProcessLoginResponse(a);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool ProcessLoginResponse(ApiResponse a)
|
private static bool ProcessLoginResponse(ApiResponse a)
|
||||||
@@ -159,12 +177,12 @@ namespace AyaNovaQBI
|
|||||||
{
|
{
|
||||||
return false;
|
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");
|
throw new Exception("Server login from QBI is disabled due to AyaNova license issue");
|
||||||
}
|
}
|
||||||
|
|
||||||
JWT = a.ObjectResponse["data"]["token"].Value<string>();
|
JWT = a.ObjectResponse["data"]["token"].Value<string>();
|
||||||
|
|
||||||
AyaNovaUserName = a.ObjectResponse["data"]["name"].Value<string>();
|
AyaNovaUserName = a.ObjectResponse["data"]["name"].Value<string>();
|
||||||
AyaNovaUserRoles = (AuthorizationRoles)(int.Parse(a.ObjectResponse["data"]["roles"].Value<string>()));
|
AyaNovaUserRoles = (AuthorizationRoles)(int.Parse(a.ObjectResponse["data"]["roles"].Value<string>()));
|
||||||
@@ -463,11 +481,15 @@ namespace AyaNovaQBI
|
|||||||
|
|
||||||
//Get license
|
//Get license
|
||||||
var r = await GetAsync("license");
|
var r = await GetAsync("license");
|
||||||
ALicense = r.ObjectResponse["data"]["license"].ToObject < AyaNovaLicense>();
|
ALicense = r.ObjectResponse["data"]["license"].ToObject<AyaNovaLicense>();
|
||||||
|
|
||||||
|
|
||||||
//UNEXPIRED AYANOVA LICENSE?
|
//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?
|
//QBI LICENSED?
|
||||||
@@ -477,7 +499,7 @@ namespace AyaNovaQBI
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//check if build date is within licensed date (how did I do that automated build date thing?)
|
//check if build date is within licensed date (how did I do that automated build date thing?)
|
||||||
// copy timestamp.cs and the createtimestamp.exe utility from v7 qbi and create build event to run it here and do same thing
|
// copy timestamp.cs and the createtimestamp.exe utility from v7 qbi and create build event to run it here and do same thing
|
||||||
//check that AyaNova version matches required minimum for this QBI (
|
//check that AyaNova version matches required minimum for this QBI (
|
||||||
|
|||||||
Reference in New Issue
Block a user