This commit is contained in:
2020-11-27 16:14:14 +00:00
parent 066f8eec19
commit 945de40c16
6 changed files with 26 additions and 7 deletions

View File

@@ -0,0 +1,11 @@
using System.Collections.Generic;
namespace AyaNova.Api.ControllerHelpers
{
internal static class ImportModeFromContext
{
internal static bool ImportMode(IDictionary<object, object> HttpContextItems)
{
return HttpContextItems["AY_IMPORT_MODE"] != null;
}
}
}//eons

View File

@@ -463,6 +463,11 @@ namespace AyaNova
context.Request.HttpContext.Items["AY_USER_ID"] = u.id;
context.Request.HttpContext.Items["AY_TRANSLATION_ID"] = u.translationId;
//Is import mode header set?
context.Request.HttpContext.Items["AY_IMPORT_MODE"]= context.Request.Headers.ContainsKey("X-AY-Import-Mode");
//CHECK JWT
if (
!context.Request.Path.Value.EndsWith("/auth") &&

View File

@@ -13,7 +13,8 @@ namespace AyaNova.Biz
public BizObject()
{
//default
ImportMode=false;
}
@@ -27,6 +28,7 @@ namespace AyaNova.Biz
internal long UserId { get; set; }
internal long UserTranslationId { get; set; }
internal AuthorizationRoles CurrentUserRoles { get; set; }
internal bool ImportMode { get; set; }//mostly for v8 migrate notification disabling purposes but could be used for other things D.T.R. (down the road)
#endregion

View File

@@ -12,7 +12,7 @@ namespace AyaNova.Biz
//Returns the biz object class that corresponds to the type presented
//Used by SEARCH and objects with JOBS
internal static BizObject GetBizObject(AyaType ayaType, AyContext ct, long userId = 1, AuthorizationRoles roles = AuthorizationRoles.All)
internal static BizObject GetBizObject(AyaType ayaType, AyContext ct, long userId = 1, AuthorizationRoles roles = AuthorizationRoles.All, bool InImportMode=false)
{
switch (ayaType)
@@ -33,7 +33,7 @@ namespace AyaNova.Biz
case AyaType.FileAttachment:
return new AttachmentBiz(ct, userId, roles);
case AyaType.Customer:
return new CustomerBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
return new CustomerBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles, InImportMode);
case AyaType.CustomerNote:
return new CustomerNoteBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
case AyaType.User:

View File

@@ -13,21 +13,22 @@ namespace AyaNova.Biz
{
internal class CustomerBiz : BizObject, IJobObject, ISearchAbleObject, IReportAbleObject, IExportAbleObject, IImportAbleObject
{
internal CustomerBiz(AyContext dbcontext, long currentUserId, long userTranslationId, AuthorizationRoles UserRoles)
internal CustomerBiz(AyContext dbcontext, long currentUserId, long userTranslationId, AuthorizationRoles UserRoles, bool InImportMode)
{
ct = dbcontext;
UserId = currentUserId;
UserTranslationId = userTranslationId;
CurrentUserRoles = UserRoles;
BizType = AyaType.Customer;
ImportMode = InImportMode;
}
internal static CustomerBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext = null)
{
if (httpContext != null)
return new CustomerBiz(ct, UserIdFromContext.Id(httpContext.Items), UserTranslationIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items));
return new CustomerBiz(ct, UserIdFromContext.Id(httpContext.Items), UserTranslationIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items), ImportModeFromContext.ImportMode(httpContext.Items));
else
return new CustomerBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, AuthorizationRoles.BizAdminFull);
return new CustomerBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, AuthorizationRoles.BizAdminFull, false);
}
////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -251,7 +251,7 @@ namespace AyaNova.Util
/////////////////////////////////////////////////////////
// Erase all user entered data from the db
// This is called by seeder for trial seeding purposes
//
// and by v8 migrate v7 exporter
internal static async Task EmptyBizDataFromDatabaseForSeedingOrImportingAsync(ILogger _log)
{