This commit is contained in:
2023-02-15 23:26:05 +00:00
parent 82cacacfde
commit 98cb68850e
6 changed files with 61 additions and 8 deletions

View File

@@ -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

View File

@@ -43,11 +43,18 @@ namespace Sockeye.Biz
//
internal async Task<License> 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<bool> 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");

View File

@@ -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

View File

@@ -50,6 +50,22 @@ namespace Sockeye.Util
}
}
/// <summary>
/// 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
/// </summary>
/// <returns></returns>
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
}
}
/// <summary>
/// returns a UTC short date, short time formatted date for local display to end user in logs, errors etc at the server level