Browse Source

fixed logic error on middleware

pull/2625/head
Galip Tolga Erdem 7 years ago
parent
commit
cce337439a
  1. 11
      framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Auditing/AbpAuditingMiddleware.cs

11
framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Auditing/AbpAuditingMiddleware.cs

@ -28,11 +28,6 @@ namespace Volo.Abp.AspNetCore.Auditing
public async Task InvokeAsync(HttpContext context, RequestDelegate next) public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{ {
if (!ShouldWriteAuditLog(context))
{
await next(context).ConfigureAwait(false);
return;
}
bool hasError = false; bool hasError = false;
using (var scope = _auditingManager.BeginScope()) using (var scope = _auditingManager.BeginScope())
{ {
@ -53,7 +48,7 @@ namespace Volo.Abp.AspNetCore.Auditing
if (ShouldWriteAuditLog(context, hasError)) if (ShouldWriteAuditLog(context, hasError))
{ {
await scope.SaveAsync().ConfigureAwait(false); await scope.SaveAsync().ConfigureAwait(false);
} }
} }
} }
} }
@ -65,10 +60,10 @@ namespace Volo.Abp.AspNetCore.Auditing
return false; return false;
} }
if (Options.AlwaysLogOnException || hasError) if (Options.AlwaysLogOnException && hasError)
{ {
return true; return true;
} }
if (!Options.IsEnabledForAnonymousUsers && !CurrentUser.IsAuthenticated) if (!Options.IsEnabledForAnonymousUsers && !CurrentUser.IsAuthenticated)
{ {

Loading…
Cancel
Save