This commit is contained in:
2020-01-27 22:36:56 +00:00
parent 0d6fa8a072
commit 3402eb0a17
5 changed files with 32 additions and 22 deletions

View File

@@ -5,6 +5,17 @@ using System.Linq;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.JsonPatch;
using EnumsNET;
using AyaNova.Util;
using AyaNova.Api.ControllerHelpers;
using AyaNova.Models;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
namespace AyaNova.Util
{
@@ -325,7 +336,7 @@ namespace AyaNova.Util
// Check if DB is empty
// CALLED BY LICENSE CONTROLLER AND LICENSE.CS FOR TRIAL Request check
// Also called by Import
internal static bool DBIsEmpty(AyContext ct, ILogger _log)
internal static async Task<bool> DBIsEmptyAsync(AyContext ct, ILogger _log)
{
//TODO: This needs to be way more thorough, only the main tables though, no need to get crazy with it
//just stuff that would be shitty to have to re-enter
@@ -333,7 +344,8 @@ namespace AyaNova.Util
_log.LogDebug("DB empty check");
//An empty db contains only one User
if (ct.User.Count() > 1) return false;
if (await ct.User.LongCountAsync() > 1) return false;
//No clients
//if(ctx.Client.Count()>0) return false;

View File

@@ -11,12 +11,9 @@ using Microsoft.Extensions.Logging;
using Microsoft.EntityFrameworkCore;
//JSON KEY
using Newtonsoft.Json;
using Org.BouncyCastle.Security;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.OpenSsl;
//using System.Security.Cryptography;
//using Microsoft.AspNetCore.Cryptography.KeyDerivation;
@@ -522,7 +519,7 @@ namespace AyaNova.Core
}
//Can't install a trial into a non-empty db
if (ParsedNewKey.TrialLicense && !DbUtil.DBIsEmptyAsync(ct, log))
if (ParsedNewKey.TrialLicense && ! DbUtil.DBIsEmptyAsync(ct, log))
{
throw new ApplicationException("E1020 - Can't install a trial key into a non empty AyaNova database. Erase the database first.");
}