Browse Source

Merge pull request #1942 from gdlcf88/reset-password

Update for resetting user password in UserManagement module.
pull/1956/head
Yunus Emre Kalkan 7 years ago
committed by GitHub
parent
commit
167d9e5940
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserUpdateDto.cs
  2. 7
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs
  3. 4
      modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs
  4. 1
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml
  5. 4
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs
  6. 1
      modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserAppService_Tests.cs
  7. 4
      npm/ng-packs/packages/identity/src/lib/components/users/users.component.html
  8. 2
      npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts

6
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 namespace Volo.Abp.Identity
{ {
public class IdentityUserUpdateDto : IdentityUserCreateOrUpdateDtoBase, IHasConcurrencyStamp public class IdentityUserUpdateDto : IdentityUserCreateOrUpdateDtoBase, IHasConcurrencyStamp
{ {
[StringLength(IdentityUserConsts.MaxPasswordLength)]
public string Password { get; set; }
public string ConcurrencyStamp { get; set; } public string ConcurrencyStamp { get; set; }
} }
} }

7
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 _userManager.SetUserNameAsync(user, input.UserName)).CheckErrors();
await UpdateUserByInput(user, input); await UpdateUserByInput(user, input);
(await _userManager.UpdateAsync(user)).CheckErrors(); (await _userManager.UpdateAsync(user)).CheckErrors();
if (!input.Password.IsNullOrEmpty())
{
(await _userManager.RemovePasswordAsync(user)).CheckErrors();
(await _userManager.AddPasswordAsync(user, input.Password)).CheckErrors();
}
await CurrentUnitOfWork.SaveChangesAsync(); await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map<IdentityUser, IdentityUserDto>(user); return ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);

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

@ -1,4 +1,5 @@
using AutoMapper; using AutoMapper;
using Volo.Abp.AutoMapper;
using Volo.Abp.Identity.Web.Pages.Identity.Roles; using Volo.Abp.Identity.Web.Pages.Identity.Roles;
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;
@ -16,7 +17,8 @@ namespace Volo.Abp.Identity.Web
private void CreateUserMappings() private void CreateUserMappings()
{ {
//List //List
CreateMap<IdentityUserDto, EditUserModalModel.UserInfoViewModel>(); CreateMap<IdentityUserDto, EditUserModalModel.UserInfoViewModel>()
.Ignore(x => x.Password);
//CreateModal //CreateModal
CreateMap<CreateUserModalModel.UserInfoViewModel, IdentityUserCreateDto>() CreateMap<CreateUserModalModel.UserInfoViewModel, IdentityUserCreateDto>()

1
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml

@ -19,6 +19,7 @@
<abp-input asp-for="UserInfo.UserName" /> <abp-input asp-for="UserInfo.UserName" />
<abp-input asp-for="UserInfo.Name" /> <abp-input asp-for="UserInfo.Name" />
<abp-input asp-for="UserInfo.Surname" /> <abp-input asp-for="UserInfo.Surname" />
<abp-input asp-for="UserInfo.Password" />
<abp-input asp-for="UserInfo.Email" /> <abp-input asp-for="UserInfo.Email" />
<abp-input asp-for="UserInfo.PhoneNumber" /> <abp-input asp-for="UserInfo.PhoneNumber" />
<abp-input asp-for="UserInfo.LockoutEnabled" /> <abp-input asp-for="UserInfo.LockoutEnabled" />

4
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)] [StringLength(IdentityUserConsts.MaxSurnameLength)]
public string Surname { get; set; } public string Surname { get; set; }
[StringLength(IdentityUserConsts.MaxPasswordLength)]
[DataType(DataType.Password)]
public string Password { get; set; }
[Required] [Required]
[EmailAddress] [EmailAddress]
[StringLength(IdentityUserConsts.MaxEmailLength)] [StringLength(IdentityUserConsts.MaxEmailLength)]

1
modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityUserAppService_Tests.cs

@ -100,6 +100,7 @@ namespace Volo.Abp.Identity
LockoutEnabled = true, LockoutEnabled = true,
TwoFactorEnabled = true, TwoFactorEnabled = true,
PhoneNumber = CreateRandomPhoneNumber(), PhoneNumber = CreateRandomPhoneNumber(),
Password = "123qwe4R*",
Email = CreateRandomEmail(), Email = CreateRandomEmail(),
RoleNames = new[] { "admin", "moderator" }, RoleNames = new[] { "admin", "moderator" },
ConcurrencyStamp = johnNash.ConcurrencyStamp, ConcurrencyStamp = johnNash.ConcurrencyStamp,

4
npm/ng-packs/packages/identity/src/lib/components/users/users.component.html

@ -137,9 +137,9 @@
<input type="text" id="surname" class="form-control" formControlName="surname" /> <input type="text" id="surname" class="form-control" formControlName="surname" />
</div> </div>
<div *ngIf="!selected.userName" class="form-group"> <div class="form-group">
<label for="password">{{ 'AbpIdentity::Password' | abpLocalization }}</label <label for="password">{{ 'AbpIdentity::Password' | abpLocalization }}</label
><span> * </span> ><span *ngIf="!selected.userName"> * </span>
<input <input
type="password" type="password"
id="password" id="password"

2
npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts

@ -94,6 +94,8 @@ export class UsersComponent implements OnInit {
if (!this.selected.userName) { if (!this.selected.userName) {
this.form.addControl('password', new FormControl('', [Validators.required, Validators.maxLength(32)])); this.form.addControl('password', new FormControl('', [Validators.required, Validators.maxLength(32)]));
} else {
this.form.addControl('password', new FormControl('', [Validators.maxLength(32)]));
} }
}); });
} }

Loading…
Cancel
Save