Merge branch 'master' into user-crud

pull/129/head
alirıza adıyahşi 7 years ago
commit 776b642b1a

@ -144,7 +144,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleConsoleDemo", "test\S
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.EntityFrameworkCore.Tests.SecondContext", "test\Volo.Abp.EntityFrameworkCore.Tests.SecondContext\Volo.Abp.EntityFrameworkCore.Tests.SecondContext.csproj", "{127FC2BF-DC40-4370-B845-16088328264C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Mvc.Versioning.Tests", "test\Volo.Abp.AspNetCore.Mvc.Versioning.Tests\Volo.Abp.AspNetCore.Mvc.Versioning.Tests.csproj", "{A8C8B76D-0869-4C11-AC55-DB9DD115788E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.AspNetCore.Mvc.Versioning.Tests", "test\Volo.Abp.AspNetCore.Mvc.Versioning.Tests\Volo.Abp.AspNetCore.Mvc.Versioning.Tests.csproj", "{A8C8B76D-0869-4C11-AC55-DB9DD115788E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Abp.Account", "Abp.Account", "{DB012309-74FD-4D5A-B843-DD77BF053BF4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Account.Web", "src\Volo.Abp.Account.Web\Volo.Abp.Account.Web.csproj", "{F7DDF25E-58B1-4F68-AEDA-4F2FB4F4467B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Account.Application", "src\Volo.Abp.Account.Application\Volo.Abp.Account.Application.csproj", "{723709F9-09FB-4715-A5D2-DAC8833D8CF7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Account.Application.Contracts", "src\Volo.Abp.Account.Application.Contracts\Volo.Abp.Account.Application.Contracts.csproj", "{3E62ED84-8792-4DA6-9B0A-AADEA183C2B3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -372,6 +380,18 @@ Global
{A8C8B76D-0869-4C11-AC55-DB9DD115788E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8C8B76D-0869-4C11-AC55-DB9DD115788E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8C8B76D-0869-4C11-AC55-DB9DD115788E}.Release|Any CPU.Build.0 = Release|Any CPU
{F7DDF25E-58B1-4F68-AEDA-4F2FB4F4467B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F7DDF25E-58B1-4F68-AEDA-4F2FB4F4467B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F7DDF25E-58B1-4F68-AEDA-4F2FB4F4467B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F7DDF25E-58B1-4F68-AEDA-4F2FB4F4467B}.Release|Any CPU.Build.0 = Release|Any CPU
{723709F9-09FB-4715-A5D2-DAC8833D8CF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{723709F9-09FB-4715-A5D2-DAC8833D8CF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{723709F9-09FB-4715-A5D2-DAC8833D8CF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{723709F9-09FB-4715-A5D2-DAC8833D8CF7}.Release|Any CPU.Build.0 = Release|Any CPU
{3E62ED84-8792-4DA6-9B0A-AADEA183C2B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E62ED84-8792-4DA6-9B0A-AADEA183C2B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E62ED84-8792-4DA6-9B0A-AADEA183C2B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E62ED84-8792-4DA6-9B0A-AADEA183C2B3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -441,6 +461,10 @@ Global
{2B48CF90-DBDB-469F-941C-5B5AECEEACE0} = {37087D1B-3693-4E96-983D-A69F210BDE53}
{127FC2BF-DC40-4370-B845-16088328264C} = {37087D1B-3693-4E96-983D-A69F210BDE53}
{A8C8B76D-0869-4C11-AC55-DB9DD115788E} = {37087D1B-3693-4E96-983D-A69F210BDE53}
{DB012309-74FD-4D5A-B843-DD77BF053BF4} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{F7DDF25E-58B1-4F68-AEDA-4F2FB4F4467B} = {DB012309-74FD-4D5A-B843-DD77BF053BF4}
{723709F9-09FB-4715-A5D2-DAC8833D8CF7} = {DB012309-74FD-4D5A-B843-DD77BF053BF4}
{3E62ED84-8792-4DA6-9B0A-AADEA183C2B3} = {DB012309-74FD-4D5A-B843-DD77BF053BF4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5}

@ -20,6 +20,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Volo.Abp.Account.Web\Volo.Abp.Account.Web.csproj" />
<ProjectReference Include="..\..\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" />
<ProjectReference Include="..\..\Volo.Abp.Identity.EntityFrameworkCore\Volo.Abp.Identity.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\Volo.Abp.Identity.HttpApi\Volo.Abp.Identity.HttpApi.csproj" />

@ -3,11 +3,15 @@ using AbpDesk.EntityFrameworkCore;
using AbpDesk.Web.Mvc.Navigation;
using AbpDesk.Web.Mvc.Temp;
using Autofac;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.Account.Web;
using Volo.Abp.AspNetCore.EmbeddedFiles;
using Volo.Abp.AspNetCore.Modularity;
using Volo.Abp.AspNetCore.Mvc;
@ -30,6 +34,7 @@ namespace AbpDesk.Web.Mvc
typeof(AbpIdentityHttpApiModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpIdentityWebModule),
typeof(AbpAccountWebModule),
typeof(AbpAutofacModule)
)]
public class AbpDeskWebMvcModule : AbpModule
@ -80,6 +85,8 @@ namespace AbpDesk.Web.Mvc
app.UseStaticFiles();
app.UseEmbeddedFiles();
app.UseAuthentication();
app.UseMvc(routes =>
{
routes.MapRoute(

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Volo.Abp.Account.Application.Contracts</AssemblyName>
<PackageId>Volo.Abp.Account.Application.Contracts</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp\Volo.Abp.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,13 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
namespace Volo.Abp.Account
{
public class AbpAccountApplicationContractsModule : AbpModule
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddAssemblyOf<AbpAccountApplicationContractsModule>();
}
}
}

@ -0,0 +1,8 @@
using Volo.Abp.Application.Services;
namespace Volo.Abp.Account
{
public interface ILoginAppService : IApplicationService
{
}
}

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Volo.Abp.Account.Application</AssemblyName>
<PackageId>Volo.Abp.Account.Application</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.Account.Application.Contracts\Volo.Abp.Account.Application.Contracts.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,14 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
namespace Volo.Abp.Account
{
[DependsOn(typeof(AbpAccountApplicationContractsModule))]
public class AbpAccountApplicationModule : AbpModule
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddAssemblyOf<AbpAccountApplicationModule>();
}
}
}

@ -0,0 +1,6 @@
namespace Volo.Abp.Account
{
public class LoginAppService : ILoginAppService
{
}
}

@ -0,0 +1,39 @@
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap;
using Volo.Abp.EmbeddedFiles;
using Volo.Abp.Identity;
using Volo.Abp.Modularity;
namespace Volo.Abp.Account.Web
{
[DependsOn(typeof(AbpIdentityDomainModule))]
[DependsOn(typeof(AbpAspNetCoreMvcUiBootstrapModule))]
[DependsOn(typeof(AbpAccountApplicationContractsModule))]
public class AbpAccountWebModule : AbpModule
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddAssemblyOf<AbpAccountWebModule>();
services.Configure<EmbeddedFileOptions>(options =>
{
options.Sources.Add(
new EmbeddedFileSet(
"/Areas/",
GetType().GetTypeInfo().Assembly,
"Volo.Abp.Account.Web.Areas"
)
);
options.Sources.Add(
new EmbeddedFileSet(
"/",
GetType().GetTypeInfo().Assembly,
"Volo.Abp.Account.Web.wwwroot"
)
);
});
}
}
}

@ -0,0 +1,58 @@
using System;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Ui;
namespace Volo.Abp.Account.Web.Areas.Account.Controllers
{
public abstract class AccountControllerBase : AbpController
{
protected RedirectResult RedirectSafely(string returnUrl, string returnUrlHash = null)
{
return Redirect(GetRedirectUrl(returnUrl, returnUrlHash));
}
protected void CheckIdentityErrors(IdentityResult identityResult)
{
if (!identityResult.Succeeded)
{
throw new UserFriendlyException("Operation failed!");
}
//identityResult.CheckErrors(LocalizationManager); //TODO: Get from old Abp
}
private string GetRedirectUrl(string returnUrl, string returnUrlHash = null)
{
returnUrl = NormalizeReturnUrl(returnUrl);
if (!returnUrlHash.IsNullOrWhiteSpace())
{
returnUrl = returnUrl + returnUrlHash;
}
return returnUrl;
}
private string NormalizeReturnUrl(string returnUrl)
{
if (returnUrl.IsNullOrEmpty())
{
return GetAppHomeUrl();
}
if (Url.IsLocalUrl(returnUrl))
{
return returnUrl;
}
return GetAppHomeUrl();
}
private string GetAppHomeUrl()
{
return "/"; //TODO: ???
}
}
}

@ -0,0 +1,49 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Account.Web.Areas.Account.Models.Login;
using Volo.Abp.Identity;
using Volo.Abp.Ui;
namespace Volo.Abp.Account.Web.Areas.Account.Controllers
{
[Area("Account")]
public class LoginController : AccountControllerBase
{
private readonly SignInManager<IdentityUser> _signInManager;
public LoginController(SignInManager<IdentityUser> signInManager)
{
_signInManager = signInManager;
}
public IActionResult Index()
{
return View();
}
[HttpPost]
public async Task<IActionResult> Index(LoginModel loginModel, string returnUrl = "", string returnUrlHash = "")
{
if (!ModelState.IsValid)
{
throw new NotImplementedException();
}
var result = await _signInManager.PasswordSignInAsync(
loginModel.UserNameOrEmailAddress,
loginModel.Password,
loginModel.RememberMe,
true
);
if (!result.Succeeded)
{
throw new UserFriendlyException("Login failed!"); //TODO: Handle other cases, do not throw exception
}
return RedirectSafely(returnUrl, returnUrlHash);
}
}
}

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Identity;
namespace Volo.Abp.Account.Web.Areas.Account.Controllers
{
[Area("Account")]
public class LogoutController : AccountControllerBase
{
private readonly SignInManager<IdentityUser> _signInManager;
public LogoutController(SignInManager<IdentityUser> signInManager)
{
_signInManager = signInManager;
}
public async Task<IActionResult> Index()
{
await _signInManager.SignOutAsync();
return RedirectToAction("Index", "Login");
}
}
}

@ -0,0 +1,52 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Account.Web.Areas.Account.Models.Register;
using Volo.Abp.Identity;
namespace Volo.Abp.Account.Web.Areas.Account.Controllers
{
[Area("Account")]
public class RegisterController : AccountControllerBase
{
private readonly IdentityUserManager _userManager;
private readonly SignInManager<IdentityUser> _signInManager;
public RegisterController(IdentityUserManager userManager, SignInManager<IdentityUser> signInManager)
{
_userManager = userManager;
_signInManager = signInManager;
}
public IActionResult Index()
{
return View();
}
[HttpPost]
//TODO: [ValidateAntiForgeryToken]
public async Task<IActionResult> Index(RegisterModel registerModel, string returnUrl = "", string returnUrlHash = "")
{
if (!ModelState.IsValid)
{
throw new NotImplementedException();
}
var user = new IdentityUser(GuidGenerator.Create(), registerModel.UserName);
var result = await _userManager.CreateAsync(user, registerModel.Password);
if (!result.Succeeded)
{
throw new NotImplementedException();
}
await _userManager.SetEmailAsync(user, registerModel.EmailAddress);
await _signInManager.SignInAsync(user, isPersistent: false);
return RedirectSafely(returnUrl, returnUrlHash);
}
}
}

@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations;
namespace Volo.Abp.Account.Web.Areas.Account.Models.Login
{
public class LoginModel
{
[Required]
[MaxLength(255)]
public string UserNameOrEmailAddress { get; set; }
[Required]
[MaxLength(32)]
public string Password { get; set; }
public bool RememberMe { get; set; }
}
}

@ -0,0 +1,20 @@
using System.ComponentModel.DataAnnotations;
namespace Volo.Abp.Account.Web.Areas.Account.Models.Register
{
public class RegisterModel
{
[Required]
[MaxLength(32)]
public string UserName { get; set; }
[Required]
[EmailAddress]
[MaxLength(255)]
public string EmailAddress { get; set; }
[Required]
[MaxLength(32)]
public string Password { get; set; }
}
}

@ -0,0 +1,25 @@
<div class="row">
<div class="col-md-3">
<form asp-action="Index" method="post">
<div class="form-group">
<label for="UsernameOrEmailAddress">Username or email address</label>
<input type="text" class="form-control" id="UsernameOrEmailAddress" name="UsernameOrEmailAddress">
</div>
<div class="form-group">
<label for="Password">Password</label>
<input type="password" class="form-control" id="Password" name="Password">
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" name="RememberMe" value="true" checked="checked">
Remember me
</label>
</div>
<button type="submit" class="btn btn-primary">Login</button>
</form>
<div>
<a href="@Url.Action("Index", "Register", new { returnUrl = Context.Request.Query["returnUrl"], returnUrlHash = Context.Request.Query["returnUrlHash"] })">Register</a>
</div>
</div>
</div>

@ -0,0 +1,19 @@
<div class="row">
<div class="col-md-3">
<form asp-action="Index" method="post">
<div class="form-group">
<label for="UserName">Username</label>
<input type="text" class="form-control" id="UserName" name="UserName" required>
</div>
<div class="form-group">
<label for="EmailAddress">Email address</label>
<input type="email" class="form-control" id="EmailAddress" name="EmailAddress" required>
</div>
<div class="form-group">
<label for="Password">Password</label>
<input type="password" class="form-control" id="Password" name="Password" required>
</div>
<button type="submit" class="btn btn-primary">Register</button>
</form>
</div>
</div>

@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Volo.Abp.Account.Web</AssemblyName>
<PackageId>Volo.Abp.Account.Web</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<RootNamespace>Volo.Abp.Account.Web</RootNamespace>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="Areas\**\*.*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.Account.Application.Contracts\Volo.Abp.Account.Application.Contracts.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.csproj" />
<ProjectReference Include="..\Volo.Abp.Identity.Domain\Volo.Abp.Identity.Domain.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
</Project>

@ -16,8 +16,6 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap
services.Configure<EmbeddedFileOptions>(options =>
{
//TODO: Move libs under wwwroot!
options.Sources.Add(
new EmbeddedFileSet(
"/",

@ -32,9 +32,12 @@
}
}
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
@if (Context.User?.Identity?.IsAuthenticated == true)
{
<div>
<a href="/Account/Logout">Logout</a> /* TODO: ?? */
</div>
}
</div>
</nav>

@ -10,7 +10,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Fixed top navbar example for Bootstrap</title>
<title>ABP Web Application</title>
<vc:abp-style-bundle name="GlobalStyles"></vc:abp-style-bundle>

@ -66,8 +66,7 @@ namespace Volo.Abp.Identity
var user = new IdentityUser(GuidGenerator.Create(), input.UserName);
await UpdateUserByInput(user, input);
await _userManager.AddPasswordAsync(user, input.Password);
await _userManager.CreateAsync(user);
await _userManager.CreateAsync(user, input.Password);
await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);

@ -0,0 +1,44 @@
using System;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Volo.Abp.Identity;
namespace Microsoft.Extensions.DependencyInjection
{
//TODO: AspNetUserManager overrides CancellationToken so we can make same functionality available!
public static class AbpIdentityServiceCollectionExtensions
{
public static IdentityBuilder AddAbpIdentity(this IServiceCollection services)
{
return services.AddAbpIdentity(setupAction: null);
}
public static IdentityBuilder AddAbpIdentity(this IServiceCollection services, Action<IdentityOptions> setupAction)
{
//AbpRoleManager
services.TryAddScoped<IdentityRoleManager>();
services.TryAddScoped(typeof(RoleManager<IdentityRole>), provider => provider.GetService(typeof(IdentityRoleManager)));
//AbpUserManager
services.TryAddScoped<IdentityUserManager>();
services.TryAddScoped(typeof(UserManager<IdentityUser>), provider => provider.GetService(typeof(IdentityUserManager)));
//AbpSecurityStampValidator TODO: We may need to add this in order to ValidateAsync principal!
//services.TryAddScoped<AbpSecurityStampValidator<TTenant, TRole, TUser>>();
//services.TryAddScoped(typeof(SecurityStampValidator<TUser>), provider => provider.GetService(typeof(AbpSecurityStampValidator<TTenant, TRole, TUser>)));
//services.TryAddScoped(typeof(ISecurityStampValidator), provider => provider.GetService(typeof(AbpSecurityStampValidator<TTenant, TRole, TUser>)));
//AbpUserStore
services.TryAddScoped<IdentityUserStore>();
services.TryAddScoped(typeof(IUserStore<IdentityUser>), provider => provider.GetService(typeof(IdentityUserStore)));
//AbpRoleStore
services.TryAddScoped<IdentityRoleStore>();
services.TryAddScoped(typeof(IRoleStore<IdentityRole>), provider => provider.GetService(typeof(IdentityRoleStore)));
return services.AddIdentity<IdentityUser, IdentityRole>(setupAction);
//return services.AddIdentityCore<IdentityUser>(setupAction);
}
}
}

@ -9,7 +9,7 @@ namespace Volo.Abp.Identity
public override void ConfigureServices(IServiceCollection services)
{
//TODO: How to configure options of AddIdentity (and return value)
services.AddIdentity<IdentityUser, IdentityRole>();
services.AddAbpIdentity();
services.AddAssemblyOf<AbpIdentityDomainModule>();
}
}

@ -8,6 +8,7 @@ using JetBrains.Annotations;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Guids;
using Volo.Abp.Uow;
@ -262,13 +263,15 @@ namespace Volo.Abp.Identity
/// <param name="role">The role whose claims should be retrieved.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>A <see cref="Task{TResult}"/> that contains the claims granted to a role.</returns>
public Task<IList<Claim>> GetClaimsAsync([NotNull] IdentityRole role, CancellationToken cancellationToken = default(CancellationToken))
public async Task<IList<Claim>> GetClaimsAsync([NotNull] IdentityRole role, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
Check.NotNull(role, nameof(role));
return Task.FromResult<IList<Claim>>(role.Claims.Select(c => c.ToClaim()).ToList());
await _roleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken);
return role.Claims.Select(c => c.ToClaim()).ToList();
}
/// <summary>
@ -278,16 +281,16 @@ namespace Volo.Abp.Identity
/// <param name="claim">The claim to add to the role.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public Task AddClaimAsync([NotNull] IdentityRole role, [NotNull] Claim claim, CancellationToken cancellationToken = default(CancellationToken))
public async Task AddClaimAsync([NotNull] IdentityRole role, [NotNull] Claim claim, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
Check.NotNull(role, nameof(role));
Check.NotNull(claim, nameof(claim));
role.AddClaim(_guidGenerator, claim);
await _roleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken);
return Task.FromResult(false);
role.AddClaim(_guidGenerator, claim);
}
/// <summary>
@ -297,14 +300,14 @@ namespace Volo.Abp.Identity
/// <param name="claim">The claim to remove from the role.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public Task RemoveClaimAsync([NotNull] IdentityRole role, [NotNull] Claim claim, CancellationToken cancellationToken = default(CancellationToken))
public async Task RemoveClaimAsync([NotNull] IdentityRole role, [NotNull] Claim claim, CancellationToken cancellationToken = default(CancellationToken))
{
Check.NotNull(role, nameof(role));
Check.NotNull(claim, nameof(claim));
role.RemoveClaim(claim);
await _roleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken);
return Task.CompletedTask;
role.RemoveClaim(claim);
}
}
}

@ -418,13 +418,15 @@ namespace Volo.Abp.Identity
/// <param name="user">The user whose claims should be retrieved.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>A <see cref="Task{TResult}"/> that contains the claims granted to a user.</returns>
public virtual Task<IList<Claim>> GetClaimsAsync([NotNull] IdentityUser user, CancellationToken cancellationToken = default(CancellationToken))
public virtual async Task<IList<Claim>> GetClaimsAsync([NotNull] IdentityUser user, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
Check.NotNull(user, nameof(user));
return Task.FromResult<IList<Claim>>(user.Claims.Select(c => c.ToClaim()).ToList());
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken);
return user.Claims.Select(c => c.ToClaim()).ToList();
}
/// <summary>
@ -434,16 +436,16 @@ namespace Volo.Abp.Identity
/// <param name="claims">The claim to add to the user.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public virtual Task AddClaimsAsync([NotNull] IdentityUser user, [NotNull] IEnumerable<Claim> claims, CancellationToken cancellationToken = default(CancellationToken))
public virtual async Task AddClaimsAsync([NotNull] IdentityUser user, [NotNull] IEnumerable<Claim> claims, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
Check.NotNull(user, nameof(user));
Check.NotNull(claims, nameof(claims));
user.AddClaims(_guidGenerator, claims);
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken);
return Task.CompletedTask;
user.AddClaims(_guidGenerator, claims);
}
/// <summary>
@ -454,7 +456,7 @@ namespace Volo.Abp.Identity
/// <param name="newClaim">The new claim replacing the <paramref name="claim"/>.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public virtual Task ReplaceClaimAsync([NotNull] IdentityUser user, [NotNull] Claim claim, [NotNull] Claim newClaim, CancellationToken cancellationToken = default(CancellationToken))
public virtual async Task ReplaceClaimAsync([NotNull] IdentityUser user, [NotNull] Claim claim, [NotNull] Claim newClaim, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
@ -462,9 +464,9 @@ namespace Volo.Abp.Identity
Check.NotNull(claim, nameof(claim));
Check.NotNull(newClaim, nameof(newClaim));
user.ReplaceClaim(claim, newClaim);
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken);
return Task.CompletedTask;
user.ReplaceClaim(claim, newClaim);
}
/// <summary>
@ -474,16 +476,16 @@ namespace Volo.Abp.Identity
/// <param name="claims">The claim to remove.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public virtual Task RemoveClaimsAsync([NotNull] IdentityUser user, [NotNull] IEnumerable<Claim> claims, CancellationToken cancellationToken = default(CancellationToken))
public virtual async Task RemoveClaimsAsync([NotNull] IdentityUser user, [NotNull] IEnumerable<Claim> claims, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
Check.NotNull(user, nameof(user));
Check.NotNull(claims, nameof(claims));
user.RemoveClaims(claims);
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken);
return Task.CompletedTask;
user.RemoveClaims(claims);
}
/// <summary>
@ -493,16 +495,16 @@ namespace Volo.Abp.Identity
/// <param name="login">The login to add to the user.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public virtual Task AddLoginAsync([NotNull] IdentityUser user, [NotNull] UserLoginInfo login, CancellationToken cancellationToken = default(CancellationToken))
public virtual async Task AddLoginAsync([NotNull] IdentityUser user, [NotNull] UserLoginInfo login, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
Check.NotNull(user, nameof(user));
Check.NotNull(login, nameof(login));
user.AddLogin(_guidGenerator, login);
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Logins, cancellationToken);
return Task.CompletedTask;
user.AddLogin(_guidGenerator, login);
}
/// <summary>
@ -513,7 +515,7 @@ namespace Volo.Abp.Identity
/// <param name="providerKey">The key provided by the <paramref name="loginProvider"/> to identify a user.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public virtual Task RemoveLoginAsync([NotNull] IdentityUser user, [NotNull] string loginProvider, [NotNull] string providerKey, CancellationToken cancellationToken = default(CancellationToken))
public virtual async Task RemoveLoginAsync([NotNull] IdentityUser user, [NotNull] string loginProvider, [NotNull] string providerKey, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
@ -521,9 +523,9 @@ namespace Volo.Abp.Identity
Check.NotNull(loginProvider, nameof(loginProvider));
Check.NotNull(providerKey, nameof(providerKey));
user.RemoveLogin(loginProvider, providerKey);
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Logins, cancellationToken);
return Task.CompletedTask;
user.RemoveLogin(loginProvider, providerKey);
}
/// <summary>
@ -534,13 +536,15 @@ namespace Volo.Abp.Identity
/// <returns>
/// The <see cref="Task"/> for the asynchronous operation, containing a list of <see cref="UserLoginInfo"/> for the specified <paramref name="user"/>, if any.
/// </returns>
public virtual Task<IList<UserLoginInfo>> GetLoginsAsync([NotNull] IdentityUser user, CancellationToken cancellationToken = default(CancellationToken))
public virtual async Task<IList<UserLoginInfo>> GetLoginsAsync([NotNull] IdentityUser user, CancellationToken cancellationToken = default(CancellationToken))
{
cancellationToken.ThrowIfCancellationRequested();
Check.NotNull(user, nameof(user));
return Task.FromResult<IList<UserLoginInfo>>(user.Logins.Select(l => l.ToUserLoginInfo()).ToList());
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Logins, cancellationToken);
return user.Logins.Select(l => l.ToUserLoginInfo()).ToList();
}
/// <summary>
@ -990,15 +994,15 @@ namespace Volo.Abp.Identity
/// <param name="value">The value of the token.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public virtual Task SetTokenAsync([NotNull] IdentityUser user, string loginProvider, string name, string value, CancellationToken cancellationToken)
public virtual async Task SetTokenAsync([NotNull] IdentityUser user, string loginProvider, string name, string value, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
Check.NotNull(user, nameof(user));
user.SetToken(_guidGenerator, loginProvider, name, value);
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken);
return Task.CompletedTask;
user.SetToken(_guidGenerator, loginProvider, name, value);
}
/// <summary>
@ -1009,15 +1013,15 @@ namespace Volo.Abp.Identity
/// <param name="name">The name of the token.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public Task RemoveTokenAsync(IdentityUser user, string loginProvider, string name, CancellationToken cancellationToken)
public async Task RemoveTokenAsync(IdentityUser user, string loginProvider, string name, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
Check.NotNull(user, nameof(user));
user.RemoveToken(loginProvider, name);
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken);
return Task.CompletedTask;
user.RemoveToken(loginProvider, name);
}
/// <summary>
@ -1028,13 +1032,15 @@ namespace Volo.Abp.Identity
/// <param name="name">The name of the token.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public Task<string> GetTokenAsync(IdentityUser user, string loginProvider, string name, CancellationToken cancellationToken)
public async Task<string> GetTokenAsync(IdentityUser user, string loginProvider, string name, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
Check.NotNull(user, nameof(user));
return Task.FromResult(user.FindToken(loginProvider, name)?.Value);
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken);
return user.FindToken(loginProvider, name)?.Value;
}
public void Dispose()

@ -1,6 +1,6 @@
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap;
using Volo.Abp.EmbeddedFiles;
using Volo.Abp.Identity.Web.Navigation;
using Volo.Abp.Modularity;
@ -8,9 +8,8 @@ using Volo.Abp.Ui.Navigation;
namespace Volo.Abp.Identity.Web
{
[DependsOn(typeof(AbpAspNetCoreMvcModule))]
[DependsOn(typeof(AbpIdentityApplicationContractsModule))]
[DependsOn(typeof(AbpAspNetCoreMvcUiModule))]
[DependsOn(typeof(AbpAspNetCoreMvcUiBootstrapModule))]
public class AbpIdentityWebModule : AbpModule
{
public override void ConfigureServices(IServiceCollection services)

@ -1,11 +1,13 @@
using System;
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
namespace Volo.Abp.Identity.Web.Areas.Identity.Controllers
{
[Area("Identity")]
[Authorize]
public class UsersController : AbpController
{
private readonly IIdentityUserAppService _identityUserAppService;

@ -24,8 +24,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.UI\Volo.Abp.AspNetCore.Mvc.UI.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc\Volo.Abp.AspNetCore.Mvc.csproj" />
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.csproj" />
<ProjectReference Include="..\Volo.Abp.Identity.Application.Contracts\Volo.Abp.Identity.Application.Contracts.csproj" />
</ItemGroup>

Loading…
Cancel
Save