Browse Source
Move `AlwaysLogSelectors` to the top.
pull/11797/head
maliming
4 years ago
No known key found for this signature in database
GPG Key ID: 96224957E51C89E
3 changed files with
15 additions and
14 deletions
-
framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/Auditing/AbpAuditHubFilter.cs
-
framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Auditing/AbpAuditingMiddleware.cs
-
framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptor.cs
|
|
|
@ -79,10 +79,6 @@ public class AbpAuditHubFilter : IHubFilter |
|
|
|
private async Task<bool> ShouldWriteAuditLogAsync(AuditLogInfo auditLogInfo, IServiceProvider serviceProvider, bool hasError) |
|
|
|
{ |
|
|
|
var options = serviceProvider.GetRequiredService<IOptions<AbpAuditingOptions>>().Value; |
|
|
|
if (options.AlwaysLogOnException && hasError) |
|
|
|
{ |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var selector in options.AlwaysLogSelectors) |
|
|
|
{ |
|
|
|
@ -92,6 +88,11 @@ public class AbpAuditHubFilter : IHubFilter |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (options.AlwaysLogOnException && hasError) |
|
|
|
{ |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
if (!options.IsEnabledForAnonymousUsers && !serviceProvider.GetRequiredService<ICurrentUser>().IsAuthenticated) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
|
|
|
|
@ -100,11 +100,6 @@ public class AbpAuditingMiddleware : IMiddleware, ITransientDependency |
|
|
|
|
|
|
|
private async Task<bool> ShouldWriteAuditLogAsync(AuditLogInfo auditLogInfo, HttpContext httpContext, bool hasError) |
|
|
|
{ |
|
|
|
if (AuditingOptions.AlwaysLogOnException && hasError) |
|
|
|
{ |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var selector in AuditingOptions.AlwaysLogSelectors) |
|
|
|
{ |
|
|
|
if (await selector(auditLogInfo)) |
|
|
|
@ -113,6 +108,11 @@ public class AbpAuditingMiddleware : IMiddleware, ITransientDependency |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (AuditingOptions.AlwaysLogOnException && hasError) |
|
|
|
{ |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
if (!AuditingOptions.IsEnabledForAnonymousUsers && !CurrentUser.IsAuthenticated) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
|
|
|
|
@ -160,11 +160,6 @@ public class AuditingInterceptor : AbpInterceptor, ITransientDependency |
|
|
|
ICurrentUser currentUser, |
|
|
|
bool hasError) |
|
|
|
{ |
|
|
|
if (options.AlwaysLogOnException && hasError) |
|
|
|
{ |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var selector in options.AlwaysLogSelectors) |
|
|
|
{ |
|
|
|
if (await selector(auditLogInfo)) |
|
|
|
@ -173,6 +168,11 @@ public class AuditingInterceptor : AbpInterceptor, ITransientDependency |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (options.AlwaysLogOnException && hasError) |
|
|
|
{ |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
if (!options.IsEnabledForAnonymousUsers && !currentUser.IsAuthenticated) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
|