Merge pull request #2880 from abpframework/maliming/auditlogs

Fixed the bug that the controller was not logged.
pull/2867/head^2
Halil İbrahim Kalkan 6 years ago committed by GitHub
commit decf4c7d34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -84,12 +84,6 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
return false;
}
//TODO: This is partially duplication of AuditHelper.ShouldSaveAudit method. Check why it does not work for controllers
if (!AuditingInterceptorRegistrar.ShouldAuditTypeByDefault(context.Controller.GetType()))
{
return false;
}
auditLog = auditLogScope.Log;
auditLogAction = _auditingHelper.CreateAuditLogAction(
auditLog,

@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;

@ -5,7 +5,6 @@ using Volo.Abp.Auditing;
namespace Volo.Abp.AspNetCore.Mvc.Auditing
{
[Route("api/audit-test")]
[Audited]
public class AuditTestController : AbpController
{
private readonly AbpAuditingOptions _options;

@ -34,8 +34,8 @@ namespace Volo.Abp.Auditing
using (var scope = _auditingManager.BeginScope())
{
await myAuditedObject1.DoItAsync(new InputObject { Value1 = "forty-two", Value2 = 42 }).ConfigureAwait(false);
await scope.SaveAsync().ConfigureAwait(false);
await myAuditedObject1.DoItAsync(new InputObject { Value1 = "forty-two", Value2 = 42 });
await scope.SaveAsync();
}
#pragma warning disable 4014
@ -80,8 +80,8 @@ namespace Volo.Abp.Auditing
using (var scope = _auditingManager.BeginScope())
{
var repository = ServiceProvider.GetRequiredService<IBasicRepository<AppEntityWithAudited, Guid>>();
await repository.InsertAsync(new AppEntityWithAudited(Guid.NewGuid(), "test name")).ConfigureAwait(false);
await scope.SaveAsync().ConfigureAwait(false);
await repository.InsertAsync(new AppEntityWithAudited(Guid.NewGuid(), "test name"));
await scope.SaveAsync();
}
#pragma warning disable 4014
@ -95,8 +95,8 @@ namespace Volo.Abp.Auditing
using (var scope = _auditingManager.BeginScope())
{
var repository = ServiceProvider.GetRequiredService<IBasicRepository<AppEntityWithAuditedAndPropertyHasDisableAuditing, Guid>>();
await repository.InsertAsync(new AppEntityWithAuditedAndPropertyHasDisableAuditing(Guid.NewGuid(), "test name", "test name2")).ConfigureAwait(false);
await scope.SaveAsync().ConfigureAwait(false);
await repository.InsertAsync(new AppEntityWithAuditedAndPropertyHasDisableAuditing(Guid.NewGuid(), "test name", "test name2"));
await scope.SaveAsync();
}
#pragma warning disable 4014
@ -113,8 +113,8 @@ namespace Volo.Abp.Auditing
using (var scope = _auditingManager.BeginScope())
{
var repository = ServiceProvider.GetRequiredService<IBasicRepository<AppEntityWithDisableAuditing, Guid>>();
await repository.InsertAsync(new AppEntityWithDisableAuditing(Guid.NewGuid(), "test name")).ConfigureAwait(false);
await scope.SaveAsync().ConfigureAwait(false);
await repository.InsertAsync(new AppEntityWithDisableAuditing(Guid.NewGuid(), "test name"));
await scope.SaveAsync();
}
#pragma warning disable 4014
@ -128,8 +128,8 @@ namespace Volo.Abp.Auditing
using (var scope = _auditingManager.BeginScope())
{
var repository = ServiceProvider.GetRequiredService<IBasicRepository<AppEntityWithSelector, Guid>>();
await repository.InsertAsync(new AppEntityWithSelector(Guid.NewGuid(), "test name")).ConfigureAwait(false);
await scope.SaveAsync().ConfigureAwait(false);
await repository.InsertAsync(new AppEntityWithSelector(Guid.NewGuid(), "test name"));
await scope.SaveAsync();
}
#pragma warning disable 4014
@ -143,8 +143,8 @@ namespace Volo.Abp.Auditing
using (var scope = _auditingManager.BeginScope())
{
var repository = ServiceProvider.GetRequiredService<IBasicRepository<AppEntityWithPropertyHasAudited, Guid>>();
await repository.InsertAsync(new AppEntityWithPropertyHasAudited(Guid.NewGuid(), "test name")).ConfigureAwait(false);
await scope.SaveAsync().ConfigureAwait(false);
await repository.InsertAsync(new AppEntityWithPropertyHasAudited(Guid.NewGuid(), "test name"));
await scope.SaveAsync();
}
#pragma warning disable 4014
@ -158,8 +158,8 @@ namespace Volo.Abp.Auditing
using (var scope = _auditingManager.BeginScope())
{
var repository = ServiceProvider.GetRequiredService<IBasicRepository<AppEntityWithDisableAuditingAndPropertyHasAudited, Guid>>();
await repository.InsertAsync(new AppEntityWithDisableAuditingAndPropertyHasAudited(Guid.NewGuid(), "test name", "test name2")).ConfigureAwait(false);
await scope.SaveAsync().ConfigureAwait(false);
await repository.InsertAsync(new AppEntityWithDisableAuditingAndPropertyHasAudited(Guid.NewGuid(), "test name", "test name2"));
await scope.SaveAsync();
}
#pragma warning disable 4014
@ -169,5 +169,20 @@ namespace Volo.Abp.Auditing
nameof(AppEntityWithDisableAuditingAndPropertyHasAudited.Name)));
#pragma warning restore 4014
}
[Fact]
public virtual async Task Should_Not_Write_AuditLog_If_There_No_Action_And_No_EntityChanges()
{
using (var scope = _auditingManager.BeginScope())
{
await scope.SaveAsync();
}
#pragma warning disable 4014
_auditingStore.DidNotReceive().SaveAsync(Arg.Any<AuditLogInfo>());
#pragma warning restore 4014
}
}
}

@ -29,7 +29,7 @@ namespace Volo.Abp.Account
(await UserManager.CreateAsync(user, input.Password)).CheckErrors();
await UserManager.SetEmailAsync(user,input.EmailAddress).ConfigureAwait(false);
await UserManager.SetEmailAsync(user,input.EmailAddress);
await SetDefaultRolesAsync(user);
@ -38,9 +38,9 @@ namespace Volo.Abp.Account
protected virtual async Task SetDefaultRolesAsync(IdentityUser user)
{
var defaultRoles = await _roleRepository.GetDefaultOnesAsync().ConfigureAwait(false);
var defaultRoles = await _roleRepository.GetDefaultOnesAsync();
await UserManager.SetRolesAsync(user, defaultRoles.Select(r => r.Name)).ConfigureAwait(false);
await UserManager.SetRolesAsync(user, defaultRoles.Select(r => r.Name));
}
protected virtual async Task CheckSelfRegistrationAsync()

@ -145,7 +145,7 @@ namespace Volo.Abp.Account.Web.Areas.Account.Controllers
private async Task CheckLocalLoginAsync()
{
if (!await _settingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin).ConfigureAwait(false))
if (!await _settingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin))
{
throw new UserFriendlyException(L["LocalLoginDisabledMessage"]);
}

@ -240,7 +240,7 @@ namespace Volo.Abp.Account.Web.Pages.Account
protected virtual async Task CheckLocalLoginAsync()
{
if (!await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin).ConfigureAwait(false))
if (!await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin))
{
throw new UserFriendlyException(L["LocalLoginDisabledMessage"]);
}

@ -39,7 +39,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetDefaultOnesAsync()
{
var roles = await RoleRepository.GetDefaultOnesAsync().ConfigureAwait(false);
var roles = await RoleRepository.GetDefaultOnesAsync();
foreach (var role in roles)
{

Loading…
Cancel
Save