From 95562a4f47f1dec4002ef3340cee0a0d1131e825 Mon Sep 17 00:00:00 2001 From: gdlcf88 <47396430@qq.com> Date: Fri, 18 Oct 2019 19:51:47 +0800 Subject: [PATCH 1/3] Update for resetting user password in UserManagement module. --- .../Volo/Abp/Identity/IdentityUserUpdateDto.cs | 6 +++++- .../Volo/Abp/Identity/IdentityUserAppService.cs | 7 +++++++ .../Pages/Identity/Users/EditModal.cshtml | 1 + .../Pages/Identity/Users/EditModal.cshtml.cs | 4 ++++ .../Volo/Abp/Identity/IdentityUserAppService_Tests.cs | 1 + 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserUpdateDto.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserUpdateDto.cs index a599207f23..4c1c90d4cc 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserUpdateDto.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserUpdateDto.cs @@ -1,9 +1,13 @@ -using Volo.Abp.Domain.Entities; +using System.ComponentModel.DataAnnotations; +using Volo.Abp.Domain.Entities; namespace Volo.Abp.Identity { public class IdentityUserUpdateDto : IdentityUserCreateOrUpdateDtoBase, IHasConcurrencyStamp { + [StringLength(IdentityUserConsts.MaxPasswordLength)] + public string Password { get; set; } + public string ConcurrencyStamp { get; set; } } } \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs index ad87b0041f..92717ec060 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs @@ -72,6 +72,13 @@ namespace Volo.Abp.Identity (await _userManager.SetUserNameAsync(user, input.UserName)).CheckErrors(); await UpdateUserByInput(user, input); (await _userManager.UpdateAsync(user)).CheckErrors(); + + if (!input.Password.IsNullOrEmpty()) + { + (await _userManager.RemovePasswordAsync(user)).CheckErrors(); + (await _userManager.AddPasswordAsync(user, input.Password)).CheckErrors(); + } + await CurrentUnitOfWork.SaveChangesAsync(); return ObjectMapper.Map(user); diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml index 247e59e46b..26962350e0 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml @@ -19,6 +19,7 @@ + diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs index 771b4fbcd9..364a1b4049 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs @@ -72,6 +72,10 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users [StringLength(IdentityUserConsts.MaxSurnameLength)] public string Surname { get; set; } + [StringLength(IdentityUserConsts.MaxPasswordLength)] + [DataType(DataType.Password)] + public string Password { get; set; } + [Required] [EmailAddress] [StringLength(IdentityUserConsts.MaxEmailLength)] diff --git a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserAppService_Tests.cs b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserAppService_Tests.cs index c418c261ff..6fbf23ed73 100644 --- a/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserAppService_Tests.cs +++ b/modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserAppService_Tests.cs @@ -100,6 +100,7 @@ namespace Volo.Abp.Identity LockoutEnabled = true, TwoFactorEnabled = true, PhoneNumber = CreateRandomPhoneNumber(), + Password = "123qwe4R*", Email = CreateRandomEmail(), RoleNames = new[] { "admin", "moderator" }, ConcurrencyStamp = johnNash.ConcurrencyStamp, From b307e012826ac4d63aa64d132dce475aae90e4f4 Mon Sep 17 00:00:00 2001 From: gdlcf88 <47396430@qq.com> Date: Fri, 18 Oct 2019 23:16:21 +0800 Subject: [PATCH 2/3] Update Angular UI for resetting user password in UserManagement module. --- .../identity/src/lib/components/users/users.component.html | 4 ++-- .../identity/src/lib/components/users/users.component.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html index af1381e000..8550af2e70 100644 --- a/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html +++ b/npm/ng-packs/packages/identity/src/lib/components/users/users.component.html @@ -137,9 +137,9 @@ -
+
* + > * Date: Mon, 21 Oct 2019 09:26:56 +0300 Subject: [PATCH 3/3] added missing ignor in mapping --- .../Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs b/modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs index c8651d8e88..7419a6f668 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs @@ -1,4 +1,5 @@ using AutoMapper; +using Volo.Abp.AutoMapper; using Volo.Abp.Identity.Web.Pages.Identity.Roles; using CreateUserModalModel = Volo.Abp.Identity.Web.Pages.Identity.Users.CreateModalModel; using EditUserModalModel = Volo.Abp.Identity.Web.Pages.Identity.Users.EditModalModel; @@ -16,7 +17,8 @@ namespace Volo.Abp.Identity.Web private void CreateUserMappings() { //List - CreateMap(); + CreateMap() + .Ignore(x => x.Password); //CreateModal CreateMap()