This commit is contained in:
2020-06-11 23:11:12 +00:00
parent 63b843fb54
commit f34b3907c7
2 changed files with 23 additions and 11 deletions

View File

@@ -13,6 +13,7 @@ using Microsoft.EntityFrameworkCore;
//JSON KEY
using Org.BouncyCastle.Security;
using Org.BouncyCastle.OpenSsl;
using Newtonsoft.Json;
@@ -27,8 +28,11 @@ namespace AyaNova.Core
{
//License server address
// private const string LICENSE_SERVER_URL = "https://rockfish.ayanova.com/";
#if (DEBUG)
private const string LICENSE_SERVER_URL = "http://localhost:3001/";
#else
private const string LICENSE_SERVER_URL = "https://rockfish.ayanova.com/";
#endif
//Unlicensed token
private const string UNLICENSED_TOKEN = "UNLICENSED";
@@ -436,20 +440,28 @@ namespace AyaNova.Core
/// Request a key
/// </summary>
/// <returns>Result string</returns>
internal static async Task<string> RequestTrialAsync(string email, string regto, ILogger log)
internal static async Task<string> RequestTrialAsync(RequestTrial trialRequest, ILogger log)
{
Microsoft.AspNetCore.Http.Extensions.QueryBuilder q = new Microsoft.AspNetCore.Http.Extensions.QueryBuilder();
q.Add("dbid", LicenseDbId.ToString());
q.Add("email", email);
q.Add("regto", regto);
trialRequest.DbId = ServerDbId;
log.LogDebug($"Requesting trial license for DBID {LicenseDbId.ToString()}");
string sUrl = $"{LICENSE_SERVER_URL}rvr" + q.ToQueryString();
try
{
var res = await ServiceProviderProvider.HttpClientFactory.CreateClient().GetStringAsync(sUrl);
return res;
// var content = new StringContent(jsonObject.ToString(), Encoding.UTF8, "application/json");
// var result = client.PostAsync(url, content).Result;
var content = new StringContent(JsonConvert.SerializeObject(trialRequest), Encoding.UTF8, "application/json");
var client = ServiceProviderProvider.HttpClientFactory.CreateClient();
var res = await client.PostAsync(sUrl, content);
if (res.IsSuccessStatusCode)
{
return "ok";
}
else return res.Content.ToString();
}
catch (Exception ex)
{
@@ -478,7 +490,7 @@ namespace AyaNova.Core
//FUTURE: if there is any kind of error response or REASON or LicenseFetchStatus then here is
//where to deal with it
//todo: key should hang off json data object as text version of key
//that way we can put other objects on the data return object
//that way we can put other objects on the data return object
AyaNovaLicenseKey ParsedKey = Parse(RawTextKeyFromRockfish, log);
if (ParsedKey != null)