Browse Source

Merge branch 'dev' of https://github.com/abpframework/abp into dev

pull/1810/head
mehmet-erim 7 years ago
parent
commit
ee46228870
  1. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/UserMenu/Default.cshtml
  2. 19
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json
  3. 1
      modules/account/src/Volo.Abp.Account.HttpApi/Volo.Abp.Account.HttpApi.csproj
  4. 2
      modules/account/src/Volo.Abp.Account.HttpApi/Volo/Abp/Account/AbpAccountHttpApiModule.cs
  5. 16
      modules/account/src/Volo.Abp.Account.Web/AbpAccountUserMenuContributor.cs
  6. 14
      modules/account/src/Volo.Abp.Account.Web/AbpAccountWebAutomapperProfile.cs
  7. 15
      modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs
  8. 50
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml
  9. 43
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml.cs
  10. 50
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.js
  11. 2
      modules/account/src/Volo.Abp.Account.Web/Volo.Abp.Account.Web.csproj
  12. 48
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs
  13. 54
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs
  14. 7
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityStoreAutoSaveChanges.cs
  15. 15
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityRoleManager.cs
  16. 1
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityRoleStore.cs
  17. 15
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs
  18. 1
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserStore.cs
  19. 12
      modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs
  20. 9
      modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs
  21. 20
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/ChangePasswordModal.cshtml
  22. 67
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/ChangePasswordModal.cshtml.cs
  23. 40
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/PersonalSettingsModal.cshtml
  24. 18
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/change-password-modal.js
  25. 18
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/personal-settings-modal.js
  26. 1
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj
  27. 2
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs
  28. 16
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenuContributor.cs
  29. 6
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/UserMenu/Default.cshtml

@ -21,7 +21,7 @@
var cssClass = string.IsNullOrEmpty(menuItem.CssClass) ? string.Empty : menuItem.CssClass; var cssClass = string.IsNullOrEmpty(menuItem.CssClass) ? string.Empty : menuItem.CssClass;
var disabled = menuItem.IsDisabled ? "disabled" : string.Empty; var disabled = menuItem.IsDisabled ? "disabled" : string.Empty;
<a class="dropdown-item @cssClass @disabled" href="@(menuItem.Url ?? "#")" @Html.Raw(elementId)> <a class="dropdown-item @cssClass @disabled" href="@(menuItem.Url ?? "#")" target="@menuItem.Target" @Html.Raw(elementId)>
@menuItem.DisplayName @menuItem.DisplayName
</a> </a>
} }

19
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json

@ -16,6 +16,23 @@
"Register": "Register", "Register": "Register",
"InvalidLoginRequest": "Invalid login request", "InvalidLoginRequest": "Invalid login request",
"ThereAreNoLoginSchemesConfiguredForThisClient": "There are no login schemes configured for this client.", "ThereAreNoLoginSchemesConfiguredForThisClient": "There are no login schemes configured for this client.",
"LogInUsingYourProviderAccount": "Log in using your {0} account" "LogInUsingYourProviderAccount": "Log in using your {0} account",
"DisplayName:CurrentPassword": "Current password",
"DisplayName:NewPassword": "New password",
"DisplayName:NewPasswordConfirm": "Confirm new password",
"PasswordChangedMessage": "Your password has been changed successfully.",
"DisplayName:UserName": "User name",
"DisplayName:Email": "Email",
"DisplayName:Name": "Name",
"DisplayName:Surname": "Surname",
"DisplayName:Password": "Password",
"DisplayName:EmailAddress": "Email address",
"DisplayName:PhoneNumber": "Phone number",
"PersonalSettings": "Personal settings",
"PersonalSettingsSaved": "Personal settings saved",
"PasswordChanged": "Password changed",
"NewPasswordConfirmFailed": "Please confirm the new password.",
"Manage": "Manage",
"ManageYourProfile": "Manage your profile"
} }
} }

1
modules/account/src/Volo.Abp.Account.HttpApi/Volo.Abp.Account.HttpApi.csproj

@ -12,6 +12,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Volo.Abp.Account.Application.Contracts\Volo.Abp.Account.Application.Contracts.csproj" /> <ProjectReference Include="..\Volo.Abp.Account.Application.Contracts\Volo.Abp.Account.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc\Volo.Abp.AspNetCore.Mvc.csproj" /> <ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc\Volo.Abp.AspNetCore.Mvc.csproj" />
<ProjectReference Include="..\..\..\identity\src\Volo.Abp.Identity.HttpApi\Volo.Abp.Identity.HttpApi.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

2
modules/account/src/Volo.Abp.Account.HttpApi/Volo/Abp/Account/AbpAccountHttpApiModule.cs

@ -1,6 +1,7 @@
using Localization.Resources.AbpUi; using Localization.Resources.AbpUi;
using Volo.Abp.Account.Localization; using Volo.Abp.Account.Localization;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Identity;
using Volo.Abp.Localization; using Volo.Abp.Localization;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
@ -8,6 +9,7 @@ namespace Volo.Abp.Account
{ {
[DependsOn( [DependsOn(
typeof(AbpAccountApplicationContractsModule), typeof(AbpAccountApplicationContractsModule),
typeof(AbpIdentityHttpApiModule),
typeof(AbpAspNetCoreMvcModule))] typeof(AbpAspNetCoreMvcModule))]
public class AbpAccountHttpApiModule : AbpModule public class AbpAccountHttpApiModule : AbpModule
{ {

16
modules/account/src/Volo.Abp.Account.Web/AbpAccountUserMenuContributor.cs

@ -2,17 +2,13 @@
using Localization.Resources.AbpUi; using Localization.Resources.AbpUi;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization; using Microsoft.Extensions.Localization;
using Volo.Abp.Account.Localization;
using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation;
namespace Volo.Abp.Account.Web namespace Volo.Abp.Account.Web
{ {
public class AbpAccountUserMenuContributor : IMenuContributor public class AbpAccountUserMenuContributor : IMenuContributor
{ {
public AbpAccountUserMenuContributor()
{
}
public Task ConfigureMenuAsync(MenuConfigurationContext context) public Task ConfigureMenuAsync(MenuConfigurationContext context)
{ {
if (context.Menu.Name != StandardMenus.User) if (context.Menu.Name != StandardMenus.User)
@ -20,13 +16,11 @@ namespace Volo.Abp.Account.Web
return Task.CompletedTask; return Task.CompletedTask;
} }
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<AbpUiResource>>(); var uiResource = context.ServiceProvider.GetRequiredService<IStringLocalizer<AbpUiResource>>();
var accountResource = context.ServiceProvider.GetRequiredService<IStringLocalizer<AccountResource>>();
context.Menu.AddItem(new ApplicationMenuItem("Account.ChangePassword", l["ChangePassword"], icon: "fa fa-key", url: "#", elementId: "abp-account-change-password"));
context.Menu.AddItem(new ApplicationMenuItem("Account.PersonalSettings", l["PersonalInfo"], icon: "fa fa-info", url: "#", elementId: "abp-account-personal-settings"));
context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000)); context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountResource["ManageYourProfile"], url: "/Account/Manage", icon: "fa fa-cog", order: 1000, null));
context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", uiResource["Logout"], url: "/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000));
return Task.CompletedTask; return Task.CompletedTask;
} }

14
modules/account/src/Volo.Abp.Account.Web/AbpAccountWebAutomapperProfile.cs

@ -0,0 +1,14 @@
using Volo.Abp.Account.Web.Pages.Account;
using Volo.Abp.Identity;
using AutoMapper;
namespace Volo.Abp.Account.Web
{
public class AbpAccountWebAutoMapperProfile : Profile
{
public AbpAccountWebAutoMapperProfile()
{
CreateMap<ProfileDto, PersonalSettingsInfoModel>();
}
}
}

15
modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs

@ -1,8 +1,10 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Account.Localization; using Volo.Abp.Account.Localization;
using Volo.Abp.AspNetCore.Mvc.Localization; using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars;
using Volo.Abp.AutoMapper;
using Volo.Abp.Identity.AspNetCore; using Volo.Abp.Identity.AspNetCore;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation;
@ -13,6 +15,7 @@ namespace Volo.Abp.Account.Web
[DependsOn( [DependsOn(
typeof(AbpAccountHttpApiModule), typeof(AbpAccountHttpApiModule),
typeof(AbpIdentityAspNetCoreModule), typeof(AbpIdentityAspNetCoreModule),
typeof(AbpAutoMapperModule),
typeof(AbpAspNetCoreMvcUiThemeSharedModule) typeof(AbpAspNetCoreMvcUiThemeSharedModule)
)] )]
public class AbpAccountWebModule : AbpModule public class AbpAccountWebModule : AbpModule
@ -41,6 +44,16 @@ namespace Volo.Abp.Account.Web
{ {
options.Contributors.Add(new AccountModuleToolbarContributor()); options.Contributors.Add(new AccountModuleToolbarContributor());
}); });
Configure<RazorPagesOptions>(options =>
{
options.Conventions.AuthorizePage("/Account/Manage");
});
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<AbpAccountWebAutoMapperProfile>(validate: true);
});
} }
} }
} }

50
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml

@ -0,0 +1,50 @@
@page
@model Volo.Abp.Account.Web.Pages.Account.ManageModel
@using Volo.Abp.Identity.Settings
@using Volo.Abp.Settings
@using Volo.Abp.AspNetCore.Mvc.UI.Theming
@inject ISettingProvider SettingManager
@inject IThemeManager ThemeManager
@inherits Volo.Abp.Account.Web.Pages.Account.AccountPage
@{
Layout = ThemeManager.CurrentTheme.GetApplicationLayout();
var isUserNameUpdateEnabled = string.Equals(await SettingManager.GetOrNullAsync(IdentitySettingNames.User.IsUserNameUpdateEnabled), "true",
StringComparison.OrdinalIgnoreCase);
var isEmailUpdateEnabled = string.Equals(await SettingManager.GetOrNullAsync(IdentitySettingNames.User.IsEmailUpdateEnabled), "true",
StringComparison.OrdinalIgnoreCase);
}
@section scripts {
<abp-script src="/Pages/Account/Manage.js" />
}
<abp-tabs tab-style="PillVertical">
<abp-tab title="@L["ChangePassword"].Value">
<abp-dynamic-form abp-model="@Model.ChangePasswordInfoModel" id="ChangePasswordForm">
<abp-form-content />
<abp-button type="submit" button-type="Primary" text="@L["Submit"].Value" />
</abp-dynamic-form>
</abp-tab>
<abp-tab title="@L["PersonalSettings"].Value">
<form method="post" id="PersonalSettingsForm">
<abp-input asp-for="PersonalSettingsInfoModel.UserName" readonly="!isUserNameUpdateEnabled" />
<abp-row>
<abp-column size-md="_6">
<abp-input asp-for="PersonalSettingsInfoModel.Name" />
</abp-column>
<abp-column size-md="_6">
<abp-input asp-for="PersonalSettingsInfoModel.Surname" />
</abp-column>
</abp-row>
<abp-input asp-for="PersonalSettingsInfoModel.Email" readonly="!isEmailUpdateEnabled" />
<abp-input asp-for="PersonalSettingsInfoModel.PhoneNumber" />
<abp-button type="submit" button-type="Primary" text="@L["Submit"].Value" />
</form>
</abp-tab>
</abp-tabs>

43
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/PersonalSettingsModal.cshtml.cs → modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml.cs

@ -1,18 +1,18 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Volo.Abp.Identity;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
namespace Volo.Abp.Identity.Web.Pages.Identity.Shared namespace Volo.Abp.Account.Web.Pages.Account
{ {
public class PersonalSettingsModal : AbpPageModel public class ManageModel : AccountPageModel
{ {
[BindProperty] public ChangePasswordInfoModel ChangePasswordInfoModel { get; set; }
public PersonalSettingsInfoModel PersonalSettingsInfoModel { get; set; } public PersonalSettingsInfoModel PersonalSettingsInfoModel { get; set; }
private readonly IProfileAppService _profileAppService; private readonly IProfileAppService _profileAppService;
public PersonalSettingsModal(IProfileAppService profileAppService) public ManageModel(IProfileAppService profileAppService)
{ {
_profileAppService = profileAppService; _profileAppService = profileAppService;
} }
@ -23,19 +23,28 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Shared
PersonalSettingsInfoModel = ObjectMapper.Map<ProfileDto, PersonalSettingsInfoModel>(user); PersonalSettingsInfoModel = ObjectMapper.Map<ProfileDto, PersonalSettingsInfoModel>(user);
} }
}
public async Task<IActionResult> OnPostAsync() public class ChangePasswordInfoModel
{ {
ValidateModel(); [Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)]
var updateDto = ObjectMapper.Map<PersonalSettingsInfoModel, UpdateProfileDto>(PersonalSettingsInfoModel); [Display(Name = "DisplayName:CurrentPassword")]
[DataType(DataType.Password)]
public string CurrentPassword { get; set; }
await _profileAppService.UpdateAsync(updateDto); [Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)]
[Display(Name = "DisplayName:NewPassword")]
[DataType(DataType.Password)]
public string NewPassword { get; set; }
return NoContent(); [Required]
} [StringLength(IdentityUserConsts.MaxPasswordLength)]
[Display(Name = "DisplayName:NewPasswordConfirm")]
[DataType(DataType.Password)]
public string NewPasswordConfirm { get; set; }
} }
public class PersonalSettingsInfoModel public class PersonalSettingsInfoModel
{ {
[Required] [Required]

50
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.js

@ -0,0 +1,50 @@
(function ($) {
var l = abp.localization.getResource('AbpAccount');
var _profileService = volo.abp.identity.profile;
$("#ChangePasswordForm").submit(function (e) {
e.preventDefault();
if (!$("#ChangePasswordForm").valid()) {
return false;
}
var input = $("#ChangePasswordForm").serializeFormToObject().changePasswordInfoModel;
if (input.newPassword != input.newPasswordConfirm || input.currentPassword == '') {
abp.message.error(l("NewPasswordConfirmFailed"));
return;
}
if (input.currentPassword == '') {
return;
}
_profileService.changePassword(
input
).then(function (result) {
abp.message.success(l("PasswordChanged"));
});
});
$("#PersonalSettingsForm").submit(function (e) {
e.preventDefault();
if (!$("#PersonalSettingsForm").valid()) {
return false;
}
var input = $("#PersonalSettingsForm").serializeFormToObject().personalSettingsInfoModel;
_profileService.update(
input
).then(function (result) {
abp.notify.success(l("PersonalSettingsSaved"));
});
});
})(jQuery);

2
modules/account/src/Volo.Abp.Account.Web/Volo.Abp.Account.Web.csproj

@ -24,12 +24,14 @@
<Content Remove="Modules\**\*.cshtml" /> <Content Remove="Modules\**\*.cshtml" />
<Content Remove="Pages\**\*.cshtml" /> <Content Remove="Pages\**\*.cshtml" />
<Content Remove="Properties\launchSettings.json" /> <Content Remove="Properties\launchSettings.json" />
<None Remove="Pages\Account\Manage.js" />
<None Include="Properties\launchSettings.json" /> <None Include="Properties\launchSettings.json" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\identity\src\Volo.Abp.Identity.AspNetCore\Volo.Abp.Identity.AspNetCore.csproj" /> <ProjectReference Include="..\..\..\identity\src\Volo.Abp.Identity.AspNetCore\Volo.Abp.Identity.AspNetCore.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj" /> <ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" />
<ProjectReference Include="..\Volo.Abp.Account.HttpApi\Volo.Abp.Account.HttpApi.csproj" /> <ProjectReference Include="..\Volo.Abp.Account.HttpApi\Volo.Abp.Account.HttpApi.csproj" />
</ItemGroup> </ItemGroup>

48
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs

@ -41,54 +41,44 @@ namespace Volo.Abp.Identity
[Authorize(IdentityPermissions.Roles.Create)] [Authorize(IdentityPermissions.Roles.Create)]
public async Task<IdentityRoleDto> CreateAsync(IdentityRoleCreateDto input) public async Task<IdentityRoleDto> CreateAsync(IdentityRoleCreateDto input)
{ {
using (_roleManager.AutoSaveRoleChanges(false)) var role = new IdentityRole(GuidGenerator.Create(), input.Name, CurrentTenant.Id);
{
var role = new IdentityRole(GuidGenerator.Create(), input.Name, CurrentTenant.Id);
role.IsDefault = input.IsDefault; role.IsDefault = input.IsDefault;
role.IsPublic = input.IsPublic; role.IsPublic = input.IsPublic;
(await _roleManager.CreateAsync(role)).CheckErrors(); (await _roleManager.CreateAsync(role)).CheckErrors();
await CurrentUnitOfWork.SaveChangesAsync(); await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map<IdentityRole, IdentityRoleDto>(role); return ObjectMapper.Map<IdentityRole, IdentityRoleDto>(role);
}
} }
[Authorize(IdentityPermissions.Roles.Update)] [Authorize(IdentityPermissions.Roles.Update)]
public async Task<IdentityRoleDto> UpdateAsync(Guid id, IdentityRoleUpdateDto input) public async Task<IdentityRoleDto> UpdateAsync(Guid id, IdentityRoleUpdateDto input)
{ {
using (_roleManager.AutoSaveRoleChanges(false)) var role = await _roleManager.GetByIdAsync(id);
{ role.ConcurrencyStamp = input.ConcurrencyStamp;
var role = await _roleManager.GetByIdAsync(id);
role.ConcurrencyStamp = input.ConcurrencyStamp;
(await _roleManager.SetRoleNameAsync(role, input.Name)).CheckErrors(); (await _roleManager.SetRoleNameAsync(role, input.Name)).CheckErrors();
role.IsDefault = input.IsDefault; role.IsDefault = input.IsDefault;
role.IsPublic = input.IsPublic; role.IsPublic = input.IsPublic;
(await _roleManager.UpdateAsync(role)).CheckErrors(); (await _roleManager.UpdateAsync(role)).CheckErrors();
await CurrentUnitOfWork.SaveChangesAsync(); await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map<IdentityRole, IdentityRoleDto>(role); return ObjectMapper.Map<IdentityRole, IdentityRoleDto>(role);
}
} }
[Authorize(IdentityPermissions.Roles.Delete)] [Authorize(IdentityPermissions.Roles.Delete)]
public async Task DeleteAsync(Guid id) public async Task DeleteAsync(Guid id)
{ {
using (_roleManager.AutoSaveRoleChanges(false)) var role = await _roleManager.FindByIdAsync(id.ToString());
if (role == null)
{ {
var role = await _roleManager.FindByIdAsync(id.ToString()); return;
if (role == null)
{
return;
}
(await _roleManager.DeleteAsync(role)).CheckErrors();
await CurrentUnitOfWork.SaveChangesAsync();
} }
(await _roleManager.DeleteAsync(role)).CheckErrors();
} }
} }
} }

54
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs

@ -53,55 +53,45 @@ namespace Volo.Abp.Identity
[Authorize(IdentityPermissions.Users.Create)] [Authorize(IdentityPermissions.Users.Create)]
public async Task<IdentityUserDto> CreateAsync(IdentityUserCreateDto input) public async Task<IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
{ {
using (_userManager.AutoSaveUserChanges(false)) var user = new IdentityUser(GuidGenerator.Create(), input.UserName, input.Email, CurrentTenant.Id);
{
var user = new IdentityUser(GuidGenerator.Create(), input.UserName, input.Email, CurrentTenant.Id);
(await _userManager.CreateAsync(user, input.Password)).CheckErrors(); (await _userManager.CreateAsync(user, input.Password)).CheckErrors();
await UpdateUserByInput(user, input); await UpdateUserByInput(user, input);
await CurrentUnitOfWork.SaveChangesAsync(); await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map<IdentityUser, IdentityUserDto>(user); return ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);
}
} }
[Authorize(IdentityPermissions.Users.Update)] [Authorize(IdentityPermissions.Users.Update)]
public async Task<IdentityUserDto> UpdateAsync(Guid id, IdentityUserUpdateDto input) public async Task<IdentityUserDto> UpdateAsync(Guid id, IdentityUserUpdateDto input)
{ {
using (_userManager.AutoSaveUserChanges(false)) var user = await _userManager.GetByIdAsync(id);
{ user.ConcurrencyStamp = input.ConcurrencyStamp;
var user = await _userManager.GetByIdAsync(id);
user.ConcurrencyStamp = input.ConcurrencyStamp;
(await _userManager.SetUserNameAsync(user, input.UserName)).CheckErrors(); (await _userManager.SetUserNameAsync(user, input.UserName)).CheckErrors();
await UpdateUserByInput(user, input); await UpdateUserByInput(user, input);
(await _userManager.UpdateAsync(user)).CheckErrors(); (await _userManager.UpdateAsync(user)).CheckErrors();
await CurrentUnitOfWork.SaveChangesAsync(); await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map<IdentityUser, IdentityUserDto>(user); return ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);
}
} }
[Authorize(IdentityPermissions.Users.Delete)] [Authorize(IdentityPermissions.Users.Delete)]
public async Task DeleteAsync(Guid id) public async Task DeleteAsync(Guid id)
{ {
using (_userManager.AutoSaveUserChanges(false)) if (CurrentUser.Id == id)
{ {
if (CurrentUser.Id == id) throw new BusinessException(code: IdentityErrorCodes.UserSelfDeletion);
{
throw new BusinessException(code: IdentityErrorCodes.UserSelfDeletion);
}
var user = await _userManager.FindByIdAsync(id.ToString());
if (user == null)
{
return;
}
(await _userManager.DeleteAsync(user)).CheckErrors();
await CurrentUnitOfWork.SaveChangesAsync();
} }
var user = await _userManager.FindByIdAsync(id.ToString());
if (user == null)
{
return;
}
(await _userManager.DeleteAsync(user)).CheckErrors();
} }
[Authorize(IdentityPermissions.Users.Update)] [Authorize(IdentityPermissions.Users.Update)]

7
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityStoreAutoSaveChanges.cs

@ -1,7 +0,0 @@
namespace Volo.Abp.Identity
{
public interface IIdentityStoreAutoSaveChanges
{
bool AutoSaveChanges { get; set; }
}
}

15
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityRoleManager.cs

@ -69,20 +69,5 @@ namespace Volo.Abp.Identity
return await base.DeleteAsync(role); return await base.DeleteAsync(role);
} }
public IDisposable AutoSaveRoleChanges(bool autoSaveChanges)
{
if (!(Store is IIdentityStoreAutoSaveChanges store))
{
throw new InvalidOperationException(Store.GetType().FullName + " does not support AutoSaveChanges");
}
var currentAutoSaveChanges = store.AutoSaveChanges;
store.AutoSaveChanges = autoSaveChanges;
return new DisposeAction(() =>
{
store.AutoSaveChanges = currentAutoSaveChanges;
});
}
} }
} }

1
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityRoleStore.cs

@ -20,7 +20,6 @@ namespace Volo.Abp.Identity
public class IdentityRoleStore : public class IdentityRoleStore :
IRoleStore<IdentityRole>, IRoleStore<IdentityRole>,
IRoleClaimStore<IdentityRole>, IRoleClaimStore<IdentityRole>,
IIdentityStoreAutoSaveChanges,
ITransientDependency ITransientDependency
{ {
private readonly IIdentityRoleRepository _roleRepository; private readonly IIdentityRoleRepository _roleRepository;

15
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs

@ -75,20 +75,5 @@ namespace Volo.Abp.Identity
return IdentityResult.Success; return IdentityResult.Success;
} }
public IDisposable AutoSaveUserChanges(bool autoSaveChanges)
{
if (!(Store is IIdentityStoreAutoSaveChanges store))
{
throw new InvalidOperationException(Store.GetType().FullName + " does not support AutoSaveChanges");
}
var currentAutoSaveChanges = store.AutoSaveChanges;
store.AutoSaveChanges = autoSaveChanges;
return new DisposeAction(() =>
{
store.AutoSaveChanges = currentAutoSaveChanges;
});
}
} }
} }

1
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserStore.cs

@ -31,7 +31,6 @@ namespace Volo.Abp.Identity
IUserAuthenticationTokenStore<IdentityUser>, IUserAuthenticationTokenStore<IdentityUser>,
IUserAuthenticatorKeyStore<IdentityUser>, IUserAuthenticatorKeyStore<IdentityUser>,
IUserTwoFactorRecoveryCodeStore<IdentityUser>, IUserTwoFactorRecoveryCodeStore<IdentityUser>,
IIdentityStoreAutoSaveChanges,
ITransientDependency ITransientDependency
{ {
private const string InternalLoginProvider = "[AspNetUserStore]"; private const string InternalLoginProvider = "[AspNetUserStore]";

12
modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs

@ -1,6 +1,5 @@
using AutoMapper; using AutoMapper;
using Volo.Abp.Identity.Web.Pages.Identity.Roles; using Volo.Abp.Identity.Web.Pages.Identity.Roles;
using Volo.Abp.Identity.Web.Pages.Identity.Shared;
using CreateUserModalModel = Volo.Abp.Identity.Web.Pages.Identity.Users.CreateModalModel; using CreateUserModalModel = Volo.Abp.Identity.Web.Pages.Identity.Users.CreateModalModel;
using EditUserModalModel = Volo.Abp.Identity.Web.Pages.Identity.Users.EditModalModel; using EditUserModalModel = Volo.Abp.Identity.Web.Pages.Identity.Users.EditModalModel;
@ -12,7 +11,6 @@ namespace Volo.Abp.Identity.Web
{ {
CreateUserMappings(); CreateUserMappings();
CreateRoleMappings(); CreateRoleMappings();
CreateProfileMappings();
} }
private void CreateUserMappings() private void CreateUserMappings()
@ -33,10 +31,6 @@ namespace Volo.Abp.Identity.Web
CreateMap<IdentityRoleDto, EditUserModalModel.AssignedRoleViewModel>() CreateMap<IdentityRoleDto, EditUserModalModel.AssignedRoleViewModel>()
.ForMember(dest => dest.IsAssigned, opt => opt.Ignore()); .ForMember(dest => dest.IsAssigned, opt => opt.Ignore());
CreateMap<ProfileDto, PersonalSettingsInfoModel>();
CreateMap<PersonalSettingsInfoModel, UpdateProfileDto>();
} }
private void CreateRoleMappings() private void CreateRoleMappings()
@ -50,11 +44,5 @@ namespace Volo.Abp.Identity.Web
//EditModal //EditModal
CreateMap<EditModalModel.RoleInfoModel, IdentityRoleUpdateDto>(); CreateMap<EditModalModel.RoleInfoModel, IdentityRoleUpdateDto>();
} }
private void CreateProfileMappings()
{
CreateMap<ProfileDto, PersonalSettingsInfoModel>();
CreateMap<PersonalSettingsInfoModel, UpdateProfileDto>();
}
} }
} }

9
modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs

@ -59,15 +59,6 @@ namespace Volo.Abp.Identity.Web
options.Conventions.AuthorizePage("/Identity/Roles/CreateModal", IdentityPermissions.Roles.Create); options.Conventions.AuthorizePage("/Identity/Roles/CreateModal", IdentityPermissions.Roles.Create);
options.Conventions.AuthorizePage("/Identity/Roles/EditModal", IdentityPermissions.Roles.Update); options.Conventions.AuthorizePage("/Identity/Roles/EditModal", IdentityPermissions.Roles.Update);
}); });
Configure<BundlingOptions>(options =>
{
options
.ScriptBundles
.Get(StandardBundles.Scripts.Global)
.AddFiles("/Pages/Identity/Shared/change-password-modal.js")
.AddFiles("/Pages/Identity/Shared/personal-settings-modal.js");
});
} }
} }
} }

20
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/ChangePasswordModal.cshtml

@ -1,20 +0,0 @@
@page
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
@using Volo.Abp.Identity.Localization
@using Volo.Abp.Identity.Web.Pages.Identity.Shared
@model ChangePasswordModal
@inject IHtmlLocalizer<IdentityResource> L
@{
Layout = null;
}
<abp-dynamic-form abp-model="@Model.ChangePasswordInfoModel" asp-page="/Identity/Shared/ChangePasswordModal">
<abp-modal>
<abp-modal-header title="@L["ChangePassword"].Value"></abp-modal-header>
<abp-modal-body>
<abp-form-content />
</abp-modal-body>
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer>
</abp-modal>
</abp-dynamic-form>

67
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/ChangePasswordModal.cshtml.cs

@ -1,67 +0,0 @@
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
using Volo.Abp.Identity.Localization;
namespace Volo.Abp.Identity.Web.Pages.Identity.Shared
{
public class ChangePasswordModal : AbpPageModel
{
[BindProperty]
public ChangePasswordInfoModel ChangePasswordInfoModel { get; set; }
private readonly IProfileAppService _profileAppService;
private readonly IStringLocalizer<IdentityResource> _localizer;
public ChangePasswordModal(
IProfileAppService profileAppService,
IStringLocalizer<IdentityResource> localizer)
{
_profileAppService = profileAppService;
_localizer = localizer;
}
public async Task<IActionResult> OnPostAsync()
{
ValidateModel();
if (ChangePasswordInfoModel.NewPassword != ChangePasswordInfoModel.NewPasswordConfirm)
{
throw new UserFriendlyException(_localizer.GetString("Identity.PasswordConfirmationFailed").Value);
}
await _profileAppService.ChangePasswordAsync(
new ChangePasswordInput()
{
CurrentPassword = ChangePasswordInfoModel.CurrentPassword,
NewPassword = ChangePasswordInfoModel.NewPassword
}
);
return NoContent();
}
}
public class ChangePasswordInfoModel
{
[Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)]
[Display(Name = "DisplayName:CurrentPassword")]
[DataType(DataType.Password)]
public string CurrentPassword { get; set; }
[Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)]
[Display(Name = "DisplayName:NewPassword")]
[DataType(DataType.Password)]
public string NewPassword { get; set; }
[Required]
[StringLength(IdentityUserConsts.MaxPasswordLength)]
[Display(Name = "DisplayName:NewPasswordConfirm")]
[DataType(DataType.Password)]
public string NewPasswordConfirm { get; set; }
}
}

40
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/PersonalSettingsModal.cshtml

@ -1,40 +0,0 @@
@page
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
@using Volo.Abp.Identity.Localization
@using Volo.Abp.Identity.Settings
@using Volo.Abp.Identity.Web.Pages.Identity.Shared
@using Volo.Abp.Settings
@model PersonalSettingsModal
@inject IHtmlLocalizer<IdentityResource> L
@inject ISettingProvider SettingProvider
@{
Layout = null;
var isUserNameUpdateEnabled = await SettingProvider.IsTrueAsync(IdentitySettingNames.User.IsUserNameUpdateEnabled);
var isEmailUpdateEnabled = await SettingProvider.IsTrueAsync(IdentitySettingNames.User.IsEmailUpdateEnabled);
}
<form asp-page="/Identity/Shared/PersonalSettingsModal">
<abp-modal>
<abp-modal-header title="@L["PersonalInfo"].Value"></abp-modal-header>
<abp-modal-body>
<abp-input asp-for="PersonalSettingsInfoModel.UserName" readonly="!isUserNameUpdateEnabled" />
<abp-row>
<abp-column size-md="_6">
<abp-input asp-for="PersonalSettingsInfoModel.Name" />
</abp-column>
<abp-column size-md="_6">
<abp-input asp-for="PersonalSettingsInfoModel.Surname" />
</abp-column>
</abp-row>
<abp-input asp-for="PersonalSettingsInfoModel.Email" readonly="!isEmailUpdateEnabled" />
<abp-input asp-for="PersonalSettingsInfoModel.PhoneNumber" />
</abp-modal-body>
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer>
</abp-modal>
</form>

18
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/change-password-modal.js

@ -1,18 +0,0 @@
(function ($) {
var l = abp.localization.getResource('AbpIdentity');
var _changePasswordModal = new abp.ModalManager(abp.appPath + 'Identity/Shared/ChangePasswordModal');
$(function () {
$("#abp-account-change-password").click(function (e) {
e.preventDefault();
_changePasswordModal.open();
});
_changePasswordModal.onResult(function () {
abp.message.success(l("PasswordChangedMessage"));
});
});
})(jQuery);

18
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/personal-settings-modal.js

@ -1,18 +0,0 @@
(function ($) {
var l = abp.localization.getResource('AbpIdentity');
var _personalSettingsModal = new abp.ModalManager(abp.appPath + 'Identity/Shared/PersonalSettingsModal');
$(function () {
$("#abp-account-personal-settings").click(function (e) {
e.preventDefault();
_personalSettingsModal.open();
});
_personalSettingsModal.onResult(function () {
//abp.message.success(l("PersonalSettingsSavedMessage"));
});
});
})(jQuery);

1
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj

@ -44,6 +44,7 @@
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> <ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" />
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj" /> <ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\account\src\Volo.Abp.Account.Web.IdentityServer\Volo.Abp.Account.Web.IdentityServer.csproj" /> <ProjectReference Include="..\..\..\..\..\modules\account\src\Volo.Abp.Account.Web.IdentityServer\Volo.Abp.Account.Web.IdentityServer.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\account\src\Volo.Abp.Account.Application\Volo.Abp.Account.Application.csproj" />
<ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj" />
</ItemGroup> </ItemGroup>

2
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs

@ -12,6 +12,7 @@ using MyCompanyName.MyProjectName.Localization;
using MyCompanyName.MyProjectName.MultiTenancy; using MyCompanyName.MyProjectName.MultiTenancy;
using StackExchange.Redis; using StackExchange.Redis;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Account;
using Volo.Abp.Account.Web; using Volo.Abp.Account.Web;
using Volo.Abp.AspNetCore.Mvc.UI; using Volo.Abp.AspNetCore.Mvc.UI;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap;
@ -32,6 +33,7 @@ namespace MyCompanyName.MyProjectName
[DependsOn( [DependsOn(
typeof(AbpAutofacModule), typeof(AbpAutofacModule),
typeof(AbpAccountWebIdentityServerModule), typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAccountApplicationModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule), typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(MyProjectNameEntityFrameworkCoreDbMigrationsModule) typeof(MyProjectNameEntityFrameworkCoreDbMigrationsModule)
)] )]

16
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenuContributor.cs

@ -1,8 +1,11 @@
using System.Threading.Tasks; using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization; using Microsoft.Extensions.Localization;
using MyCompanyName.MyProjectName.Localization; using MyCompanyName.MyProjectName.Localization;
using MyCompanyName.MyProjectName.MultiTenancy; using MyCompanyName.MyProjectName.MultiTenancy;
using Volo.Abp.Account.Localization;
using Volo.Abp.TenantManagement.Web.Navigation; using Volo.Abp.TenantManagement.Web.Navigation;
using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation;
@ -10,6 +13,13 @@ namespace MyCompanyName.MyProjectName.Web.Menus
{ {
public class MyProjectNameMenuContributor : IMenuContributor public class MyProjectNameMenuContributor : IMenuContributor
{ {
private readonly IConfigurationRoot _configurationRoot;
public MyProjectNameMenuContributor(IConfigurationRoot configurationRoot)
{
_configurationRoot = configurationRoot;
}
public async Task ConfigureMenuAsync(MenuConfigurationContext context) public async Task ConfigureMenuAsync(MenuConfigurationContext context)
{ {
if (context.Menu.Name == StandardMenus.Main) if (context.Menu.Name == StandardMenus.Main)
@ -40,7 +50,11 @@ namespace MyCompanyName.MyProjectName.Web.Menus
private Task ConfigureUserMenuAsync(MenuConfigurationContext context) private Task ConfigureUserMenuAsync(MenuConfigurationContext context)
{ {
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<MyProjectNameResource>>(); var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<MyProjectNameResource>>();
var accountStringLocalizer = context.ServiceProvider.GetRequiredService<IStringLocalizer<AccountResource>>();
var identityServerUrl = _configurationRoot["AuthServer:Authority"] ?? "";
context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountStringLocalizer["ManageYourProfile"], $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage", icon: "fa fa-cog", order: 1000, null, "_blank"));
context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000)); context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000));
return Task.CompletedTask; return Task.CompletedTask;

6
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs

@ -74,7 +74,7 @@ namespace MyCompanyName.MyProjectName.Web
ConfigureAuthentication(context, configuration); ConfigureAuthentication(context, configuration);
ConfigureAutoMapper(); ConfigureAutoMapper();
ConfigureVirtualFileSystem(hostingEnvironment); ConfigureVirtualFileSystem(hostingEnvironment);
ConfigureNavigationServices(); ConfigureNavigationServices(configuration);
ConfigureSwaggerServices(context.Services); ConfigureSwaggerServices(context.Services);
ConfigureMultiTenancy(); ConfigureMultiTenancy();
} }
@ -166,11 +166,11 @@ namespace MyCompanyName.MyProjectName.Web
} }
} }
private void ConfigureNavigationServices() private void ConfigureNavigationServices(IConfigurationRoot configuration)
{ {
Configure<NavigationOptions>(options => Configure<NavigationOptions>(options =>
{ {
options.MenuContributors.Add(new MyProjectNameMenuContributor()); options.MenuContributors.Add(new MyProjectNameMenuContributor(configuration));
}); });
} }

Loading…
Cancel
Save