Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
hikalkan committed Feb 2, 2017
2 parents eb209d0 + ea39b4a commit 1315111
Show file tree
Hide file tree
Showing 24 changed files with 244 additions and 64 deletions.
6 changes: 3 additions & 3 deletions src/Abp.Zero.AspNetCore/project.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"version": "1.3.1.0-*",
"version": "1.4.0.0-*",

"dependencies": {
"Abp.Zero": "1.3.1.0-*",
"Microsoft.AspNetCore.Mvc": "1.1.0"
"Abp.Zero": "1.4.0.0-*",
"Microsoft.AspNetCore.Mvc": "1.1.1"
},

"frameworks": {
Expand Down
6 changes: 3 additions & 3 deletions src/Abp.Zero.EntityFramework/project.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"version": "1.3.1.0-*",
"version": "1.4.0.0-*",

"dependencies": {
"Abp.EntityFramework": "1.3.1",
"Abp.Zero": "1.3.1.0-*"
"Abp.EntityFramework": "1.4.0",
"Abp.Zero": "1.4.0.0-*"
},

"frameworks": {
Expand Down
6 changes: 3 additions & 3 deletions src/Abp.Zero.EntityFrameworkCore/project.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"version": "1.3.1.0-*",
"version": "1.4.0.0-*",

"dependencies": {
"Abp.EntityFrameworkCore": "1.3.1",
"Abp.Zero": "1.3.1.0-*",
"Abp.EntityFrameworkCore": "1.4.0",
"Abp.Zero": "1.4.0.0-*",
"Microsoft.EntityFrameworkCore.Relational": "1.1.0"
},

Expand Down
4 changes: 2 additions & 2 deletions src/Abp.Zero.Ldap/project.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": "1.3.1.0-*",
"version": "1.4.0.0-*",

"dependencies": {
"Abp.Zero": "1.3.1.0-*"
"Abp.Zero": "1.4.0.0-*"
},

"frameworks": {
Expand Down
8 changes: 4 additions & 4 deletions src/Abp.Zero.NHibernate/project.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"version": "1.3.1.0-*",
"version": "1.4.0.0-*",

"dependencies": {
"Abp.FluentMigrator": "1.3.1",
"Abp.NHibernate": "1.3.1",
"Abp.Zero": "1.3.1.0-*"
"Abp.FluentMigrator": "1.4.0",
"Abp.NHibernate": "1.4.0",
"Abp.Zero": "1.4.0.0-*"
},

"frameworks": {
Expand Down
4 changes: 2 additions & 2 deletions src/Abp.Zero.Owin/project.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": "1.3.1.0-*",
"version": "1.4.0.0-*",

"dependencies": {
"Abp.Zero": "1.3.1.0-*",
"Abp.Zero": "1.4.0.0-*",
"Microsoft.AspNet.Identity.Owin": "2.2.1"
},

Expand Down
2 changes: 1 addition & 1 deletion src/Abp.Zero/Authorization/Users/AbpUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public abstract class AbpUser<TUser> : AbpUserBase, IFullAudited<TUser>, IPassiv
public virtual string PhoneNumber {get; set; }

/// <summary>
/// Is the <see cref="AbpUserBase.EmailAddress"/> confirmed.
/// Is the <see cref="AbpUser{TUser}.PhoneNumber"/> confirmed.
/// </summary>
public virtual bool IsPhoneNumberConfirmed { get; set; }

Expand Down
25 changes: 16 additions & 9 deletions src/Abp.Zero/Authorization/Users/AbpUserStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public abstract class AbpUserStore<TRole, TUser> :
private readonly IRepository<TRole> _roleRepository;
private readonly IRepository<UserPermissionSetting, long> _userPermissionSettingRepository;
private readonly IUnitOfWorkManager _unitOfWorkManager;

/// <summary>
/// Constructor.
/// </summary>
Expand Down Expand Up @@ -138,7 +138,7 @@ public virtual async Task<TUser> FindByNameOrEmailAsync(int? tenantId, string us
}

#endregion

#region IUserPasswordStore

public virtual Task SetPasswordHashAsync(TUser user, string passwordHash)
Expand Down Expand Up @@ -233,9 +233,9 @@ public virtual async Task<TUser> FindAsync(UserLoginInfo login)
public virtual Task<List<TUser>> FindAllAsync(UserLoginInfo login)
{
var query = from userLogin in _userLoginRepository.GetAll()
join user in _userRepository.GetAll() on userLogin.UserId equals user.Id
where userLogin.LoginProvider == login.LoginProvider && userLogin.ProviderKey == login.ProviderKey
select user;
join user in _userRepository.GetAll() on userLogin.UserId equals user.Id
where userLogin.LoginProvider == login.LoginProvider && userLogin.ProviderKey == login.ProviderKey
select user;

return Task.FromResult(query.ToList());
}
Expand Down Expand Up @@ -279,9 +279,9 @@ public virtual async Task RemoveFromRoleAsync(TUser user, string roleName)
public virtual async Task<IList<string>> GetRolesAsync(TUser user)
{
var query = from userRole in _userRoleRepository.GetAll()
join role in _roleRepository.GetAll() on userRole.RoleId equals role.Id
where userRole.UserId == user.Id
select role.Name;
join role in _roleRepository.GetAll() on userRole.RoleId equals role.Id
where userRole.UserId == user.Id
select role.Name;

return await AsyncQueryableExecuter.ToListAsync(query);
}
Expand Down Expand Up @@ -493,13 +493,20 @@ public Task<bool> GetTwoFactorEnabledAsync(TUser user)

public async Task<string> GetUserNameFromDatabaseAsync(long userId)
{
using (var uow = _unitOfWorkManager.Begin(new UnitOfWorkOptions()
//note: This workaround will not be needed after fixing https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1828
var outerUow = _unitOfWorkManager.Current;
using (var uow = _unitOfWorkManager.Begin(new UnitOfWorkOptions
{
Scope = TransactionScopeOption.RequiresNew,
IsTransactional = false,
IsolationLevel = IsolationLevel.ReadUncommitted
}))
{
if (outerUow != null)
{
_unitOfWorkManager.Current.SetTenantId(outerUow.GetTenantId());
}

var user = await _userRepository.GetAsync(userId);
await uow.CompleteAsync();
return user.UserName;
Expand Down
34 changes: 34 additions & 0 deletions src/Abp.Zero/MultiTenancy/TenantStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace Abp.MultiTenancy
{
public class TenantStore : ITenantStore
{
private readonly ITenantCache _tenantCache;

public TenantStore(ITenantCache tenantCache)
{
_tenantCache = tenantCache;
}

public TenantInfo Find(int tenantId)
{
var tenant = _tenantCache.GetOrNull(tenantId);
if (tenant == null)
{
return null;
}

return new TenantInfo(tenant.Id, tenant.TenancyName);
}

public TenantInfo Find(string tenancyName)
{
var tenant = _tenantCache.GetOrNull(tenancyName);
if (tenant == null)
{
return null;
}

return new TenantInfo(tenant.Id, tenant.TenancyName);
}
}
}
3 changes: 3 additions & 0 deletions src/Abp.Zero/Zero/AbpZeroCoreModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Abp.MultiTenancy;
using Abp.Reflection;
using Abp.Zero.Configuration;
using Abp.Configuration.Startup;
using Castle.MicroKernel.Registration;

namespace Abp.Zero
Expand All @@ -29,6 +30,8 @@ public override void PreInitialize()
IocManager.Register<IAbpZeroEntityTypes, AbpZeroEntityTypes>();
IocManager.Register<IAbpZeroConfig, AbpZeroConfig>();

Configuration.ReplaceService<ITenantStore, TenantStore>(DependencyLifeStyle.Transient);

Configuration.Settings.Providers.Add<AbpZeroSettingProvider>();

Configuration.Localization.Sources.Add(
Expand Down
4 changes: 2 additions & 2 deletions src/Abp.Zero/project.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": "1.3.1.0-*",
"version": "1.4.0.0-*",

"dependencies": {
"Abp": "1.3.1",
"Abp": "1.4.0",
"Microsoft.AspNet.Identity.Core": "2.2.1"
},

Expand Down
6 changes: 3 additions & 3 deletions test/Abp.Zero.SampleApp.EntityFramework/project.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"version": "1.3.1.0-*",
"version": "1.4.0.0-*",

"dependencies": {
"Abp.Zero.SampleApp": "1.3.1.0-*",
"Abp.Zero.EntityFramework": "1.3.1.0-*"
"Abp.Zero.SampleApp": "1.4.0.0-*",
"Abp.Zero.EntityFramework": "1.4.0.0-*"
},

"frameworks": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},

"dependencies": {
"Abp.Castle.Log4Net": "1.3.1",
"Abp.Castle.Log4Net": "1.4.0",
"Abp.Zero.SampleApp.EntityFrameworkCore": "1.0.0-*",
"Castle.LoggingFacility.MsLogging": "1.1.0",
"Castle.Windsor.MsDependencyInjection": "1.3.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"Shouldly": "2.8.2",
"Castle.Windsor.MsDependencyInjection": "1.3.0",
"Microsoft.EntityFrameworkCore.InMemory": "1.1.0",
"Abp.TestBase": "1.3.1"
"Abp.TestBase": "1.4.0"
},

"frameworks": {
Expand Down
4 changes: 2 additions & 2 deletions test/Abp.Zero.SampleApp.EntityFrameworkCore/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"version": "1.0.0-*",

"dependencies": {
"Abp.Zero.SampleApp": "1.3.1.0-*",
"Abp.Zero.EntityFrameworkCore": "1.3.1.0-*",
"Abp.Zero.SampleApp": "1.4.0.0-*",
"Abp.Zero.EntityFrameworkCore": "1.4.0.0-*",
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.1.0-preview4-final",
"type": "build"
Expand Down
6 changes: 3 additions & 3 deletions test/Abp.Zero.SampleApp.NHibernateTests/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"xunit.runner.visualstudio": "2.2.0-beta2-build1149",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"NSubstitute": "1.10.0",
"Abp.Zero.SampleApp": "1.3.1.0-*",
"Abp.Zero.NHibernate": "1.3.1.0-*",
"Abp.Zero.SampleApp": "1.4.0.0-*",
"Abp.Zero.NHibernate": "1.4.0.0-*",
"Shouldly": "2.8.2",
"System.Data.SQLite.Core": "1.0.104",
"Abp.TestBase": "1.3.1"
"Abp.TestBase": "1.4.0"
},

"frameworks": {
Expand Down
46 changes: 46 additions & 0 deletions test/Abp.Zero.SampleApp.Tests/MultiTenancy/TenantStore_Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Abp.MultiTenancy;
using Abp.Zero.SampleApp.MultiTenancy;
using Shouldly;
using Xunit;

namespace Abp.Zero.SampleApp.Tests.MultiTenancy
{
public class TenantStore_Tests : SampleAppTestBase
{
private readonly ITenantStore _tenantStore;

public TenantStore_Tests()
{
_tenantStore = Resolve<ITenantStore>();
}


[Fact]
public void Should_Get_Tenant_By_Id()
{
//Act
var tenant = _tenantStore.Find(1);

//Assert
Assert.NotNull(tenant);
tenant.TenancyName.ShouldBe(Tenant.DefaultTenantName);
}

[Fact]
public void Should_Get_Tenant_By_Name()
{
//Act
var tenant = _tenantStore.Find(Tenant.DefaultTenantName);

//Assert
Assert.NotNull(tenant);
tenant.Id.ShouldBe(1);
}

[Fact]
public void Should_Not_Get_Unknown_Tenant()
{
Assert.Null(_tenantStore.Find("unknown-tenancy-name"));
}
}
}
23 changes: 17 additions & 6 deletions test/Abp.Zero.SampleApp.Tests/TestDatas/InitialUsersBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,23 @@ private void CreateUsers()
var admin = _context.Users.Add(
new User
{
TenantId = defaultTenant.Id,
Name = "System",
Surname = "Administrator",
UserName = User.AdminUserName,
Password = new PasswordHasher().HashPassword("123qwe"),
EmailAddress = "[email protected]"
TenantId = defaultTenant.Id,
Name = "System",
Surname = "Administrator",
UserName = User.AdminUserName,
Password = new PasswordHasher().HashPassword("123qwe"),
EmailAddress = "[email protected]"
});

_context.Users.Add(
new User
{
TenantId = defaultTenant.Id,
Name = "System",
Surname = "Manager",
UserName = "manager",
Password = new PasswordHasher().HashPassword("123qwe"),
EmailAddress = "[email protected]"
});
}
}
Expand Down
Loading

0 comments on commit 1315111

Please sign in to comment.