diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectedWriteEntityInterceptor.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectedWriteEntityInterceptor.cs index 59b497734..03e0e1f48 100644 --- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectedWriteEntityInterceptor.cs +++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/LINGYUN/Abp/DataProtection/EntityFrameworkCore/AbpDataProtectedWriteEntityInterceptor.cs @@ -7,7 +7,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Volo.Abp; -using Volo.Abp.Authorization; using Volo.Abp.Data; using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Entities; @@ -40,7 +39,7 @@ public class AbpDataProtectedWriteEntityInterceptor : SaveChangesInterceptor, IT var entityKeys = updateEntites .Select(entity => (entity is IEntity abpEntity ? abpEntity.GetKeys() : new string[1] { entity.ToString() }).ToString()) .JoinAsString(";"); - throw new AbpAuthorizationException( + throw new AbpDataAccessDeniedException( $"Delete data permission not granted to entity {updateEntites.First().GetType()} for data {entityKeys}!"); } } @@ -56,7 +55,7 @@ public class AbpDataProtectedWriteEntityInterceptor : SaveChangesInterceptor, IT var entityKeys = deleteEntites .Select(entity => (entity is IEntity abpEntity ? abpEntity.GetKeys() : new string[1] { entity.ToString() }).ToString()) .JoinAsString(";"); - throw new AbpAuthorizationException( + throw new AbpDataAccessDeniedException( $"Delete data permission not granted to entity {deleteEntites.First().GetType()} for data {entityKeys}!"); } } diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/AbpDataAccessDeniedException.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/AbpDataAccessDeniedException.cs new file mode 100644 index 000000000..41265fc74 --- /dev/null +++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/AbpDataAccessDeniedException.cs @@ -0,0 +1,14 @@ +using Volo.Abp; + +namespace LINGYUN.Abp.DataProtection; +public class AbpDataAccessDeniedException : BusinessException +{ + public AbpDataAccessDeniedException() + { + } + + public AbpDataAccessDeniedException(string message) + : base("DataProtection:010001", message) + { + } +} diff --git a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IDataAuthorizationServiceExtensions.cs b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IDataAuthorizationServiceExtensions.cs index 6c415fec7..365969624 100644 --- a/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IDataAuthorizationServiceExtensions.cs +++ b/aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/LINGYUN/Abp/DataProtection/IDataAuthorizationServiceExtensions.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Volo.Abp.Authorization; using Volo.Abp.Domain.Entities; namespace LINGYUN.Abp.DataProtection; @@ -13,7 +12,7 @@ public static class IDataAuthorizationServiceExtensions if (!result.Succeeded) { var entityKeys = entities.Select(x => x.ToString()).JoinAsString(";"); - throw new AbpAuthorizationException( + throw new AbpDataAccessDeniedException( $"The {operation} operation with entity type {typeof(Entity)} identified as {entityKeys} is not allowed!"); } }