From 98cb68850ea7ceb558f01d36231028e79136d53b Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 15 Feb 2023 23:26:05 +0000 Subject: [PATCH] --- .vscode/launch.json | 2 +- server/Controllers/RvfController.cs | 2 ++ server/biz/LicenseBiz.cs | 30 ++++++++++++++++++++++++++--- server/models/GlobalBizSettings.cs | 8 ++++---- server/util/DateUtil.cs | 16 +++++++++++++++ todo.txt | 11 +++++++++++ 6 files changed, 61 insertions(+), 8 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index d5d28f8..7cade77 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -33,7 +33,7 @@ "SOCKEYE_DB_CONNECTION": "Server=localhost;Username=postgres;Password=sockeye;Database=sockeye;CommandTimeout=300;", "SOCKEYE_DATA_PATH": "c:\\temp\\sockeye", "SOCKEYE_USE_URLS": "http://*:7676;", - "SOCKEYE_PERMANENTLY_ERASE_DATABASE": "true", + //"SOCKEYE_PERMANENTLY_ERASE_DATABASE": "true", //"SOCKEYE_REPORT_RENDERING_TIMEOUT":"1", "SOCKEYE_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_14\\bin" }, diff --git a/server/Controllers/RvfController.cs b/server/Controllers/RvfController.cs index 93dfab8..cb59fca 100644 --- a/server/Controllers/RvfController.cs +++ b/server/Controllers/RvfController.cs @@ -6,10 +6,12 @@ using Microsoft.EntityFrameworkCore; using System.Linq; using Sockeye.Models; using Sockeye.Api.ControllerHelpers; +using Microsoft.AspNetCore.Authorization; using System.ComponentModel.DataAnnotations; namespace Sockeye.Api.Controllers { + // [AllowAnonymous] [Route("rvf")]//v8 fetch license route [Produces("application/json")] public class RvfController : ControllerBase diff --git a/server/biz/LicenseBiz.cs b/server/biz/LicenseBiz.cs index 8961f8d..2bc13c6 100644 --- a/server/biz/LicenseBiz.cs +++ b/server/biz/LicenseBiz.cs @@ -43,11 +43,18 @@ namespace Sockeye.Biz // internal async Task CreateAsync(License newObject, bool importedWithKeyDoNotGenerate = false) { + //client can send a non expiring license key but internally it MUST have a date so the + //raven default for non expiring keys is this + if (newObject.LicenseExpire == null) + { + newObject.LicenseExpire = DateUtil.EmptyDateValueForLicenseGeneration; + } await ValidateAsync(newObject, null); if (HasErrors) return null; else { + if (!importedWithKeyDoNotGenerate)//do not generate is used for initial import only from rockfish, could be removed after the initial import { await GenerateKey(newObject); @@ -105,6 +112,12 @@ namespace Sockeye.Biz } putObject.Tags = TagBiz.NormalizeTags(putObject.Tags); + //client can send a non expiring license key but internally it MUST have a date so the + //raven default for non expiring keys is this + if (putObject.LicenseExpire == null) + { + putObject.LicenseExpire = DateUtil.EmptyDateValueForLicenseGeneration; + } await ValidateAsync(putObject, dbObject); if (HasErrors) return null; await GenerateKey(putObject); @@ -244,7 +257,7 @@ MaximumDataGB: 20 } } - //////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////// //DELETE // internal async Task DeleteAsync(long id) @@ -720,7 +733,7 @@ MaximumDataGB: 20 } #endregion key gen - + //////////////////////////////////////////////////////////////////////////////////////////////// //SEARCH // @@ -761,6 +774,8 @@ MaximumDataGB: 20 { bool isNew = currentObj == null; + + //fetched keys are never editable, must be duped if re-issue //I'LL PROBABLY NEED TO CHANGE THIS LATER FOR SOME REASON BUT FOR NOW IT'S DEFENSIVE if (!isNew && currentObj.FetchedOn != null) @@ -827,6 +842,15 @@ MaximumDataGB: 20 } + //RAVEN keys *always* expire + //perpets expire in the year 5555 + if (proposedObj.LicenseExpire == null) + { + AddError(ApiErrorCode.VALIDATION_REQUIRED, "LicenseExpire"); + return; + } + + } break; case ProductGroup.RavenSubscription: @@ -838,7 +862,7 @@ MaximumDataGB: 20 } - //sub keys *always* expire + //RAVEN keys *always* expire if (proposedObj.LicenseExpire == null) { AddError(ApiErrorCode.VALIDATION_REQUIRED, "LicenseExpire"); diff --git a/server/models/GlobalBizSettings.cs b/server/models/GlobalBizSettings.cs index 485c1b5..968f185 100644 --- a/server/models/GlobalBizSettings.cs +++ b/server/models/GlobalBizSettings.cs @@ -201,16 +201,16 @@ HOW TO INSTALL YOUR LICENSE KEY 5. Click on the accept button, AyaNova will fetch the license key from our server and install it automatically"; - RavenNewKeyAvailable = @"A new AyaNova license key is available.\nAyaNova will automatically fetch it within 24 hours or you can force it to fetch immediately from the License page in AyaNova now.\n---\n{newLicense}"; + RavenNewKeyAvailable = "A new AyaNova license key is available.\nAyaNova will automatically fetch it within 24 hours or you can force it to fetch immediately from the License page in AyaNova now.\n---\n{newLicense}"; - ValidateEmail = @"Please verify your email address by clicking the link below or copy and pasting into a browser\r\n{verifyUrl}\r\nOnce your email is verified the request will be processed manually during business hours.\r\n(If you did not request this you can ignore this message)"; + ValidateEmail = "Please verify your email address by clicking the link below or copy and pasting into a browser\n{verifyUrl}\nOnce your email is verified the request will be processed manually during business hours.\n(If you did not request this you can ignore this message)"; - RavenTrialApproved = @"Your trial license request has been approved.\r\nThe license will be automatically installed shortly or you can fetch it now in the License form menu."; + RavenTrialApproved = "Your trial license request has been approved.\nThe license will be automatically installed shortly or you can fetch it now in the License form menu."; - RavenTrialRejected = @"Your trial license request was not approved.\r\n{reason}"; + RavenTrialRejected = "Your trial license request was not approved.\n{reason}"; #endregion default message templates diff --git a/server/util/DateUtil.cs b/server/util/DateUtil.cs index f0085fb..fe20773 100644 --- a/server/util/DateUtil.cs +++ b/server/util/DateUtil.cs @@ -50,6 +50,22 @@ namespace Sockeye.Util } } + /// + /// An internally consistent empty or not relevant date marker: + /// January 1st 5555 plus one day in UTC because RAVEN checks if less than EmptyDateValue above but didn't code it with timezone or UTC in mind originally + /// + /// + public static DateTime EmptyDateValueForLicenseGeneration + { + get + { + return new DateTime(5555, 1, 2, 0, 0, 0, DateTimeKind.Utc); + //Was going to use MaxValue but apparently that varies depending on culture + // and PostgreSQL has issues with year 1 as it interprets as year 2001 + // so to be on safe side just defining one for all usage + } + } + /// /// returns a UTC short date, short time formatted date for local display to end user in logs, errors etc at the server level diff --git a/todo.txt b/todo.txt index 3ac213f..ea99ef5 100644 --- a/todo.txt +++ b/todo.txt @@ -6,7 +6,18 @@ Need this basically done for now to move back to raven stuff asap. then on to all the basics, fetch licenses for v7 and v8, trial request processing trigger route, trial subscription server processing and trigger route +TODO BEFORE RELEASE +SERVER + + +CLIENT + + + + + +FUTURE STUFF - JOB: "SOCKBOT" virtual staff member, sockbot - does everything we have to do manually on a delay if it hasn't been done by us yet