Browse Source

Move change password to profile service

pull/905/head
Halil ibrahim Kalkan 7 years ago
parent
commit
dd9fbcda60
  1. 2
      modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityUserAppService.cs
  2. 2
      modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IProfileAppService.cs
  3. 12
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs
  4. 6
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs
  5. 5
      modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs
  6. 10
      modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/ProfileController.cs
  7. 13
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/ChangePasswordModal.cshtml.cs

2
modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityUserAppService.cs

@ -14,7 +14,5 @@ namespace Volo.Abp.Identity
Task<IdentityUserDto> FindByUsernameAsync(string username);
Task<IdentityUserDto> FindByEmailAsync(string email);
Task ChangePasswordAsync(string currentPassword, string newPassword);
}
}

2
modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IProfileAppService.cs

@ -8,5 +8,7 @@ namespace Volo.Abp.Identity
Task<ProfileDto> GetAsync();
Task<ProfileDto> UpdateAsync(UpdateProfileDto input);
Task ChangePasswordAsync(string currentPassword, string newPassword);
}
}

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

@ -118,18 +118,6 @@ namespace Volo.Abp.Identity
);
}
//TODO: Move this to the profile service!
public async Task ChangePasswordAsync(string currentPassword, string newPassword)
{
if (!CurrentUser.Id.HasValue)
{
throw new AbpException("Current user Id is null!");
}
var currentUser = await _userManager.GetByIdAsync(CurrentUser.Id.Value);
(await _userManager.ChangePasswordAsync(currentUser, currentPassword, newPassword)).CheckErrors();
}
private async Task UpdateUserByInput(IdentityUser user, IdentityUserCreateOrUpdateDtoBase input)
{
(await _userManager.SetEmailAsync(user, input.Email)).CheckErrors();

6
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs

@ -49,5 +49,11 @@ namespace Volo.Abp.Identity
return ObjectMapper.Map<IdentityUser, ProfileDto>(user);
}
public async Task ChangePasswordAsync(string currentPassword, string newPassword)
{
var currentUser = await _userManager.GetByIdAsync(CurrentUser.GetId());
(await _userManager.ChangePasswordAsync(currentUser, currentPassword, newPassword)).CheckErrors();
}
}
}

5
modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs

@ -64,10 +64,5 @@ namespace Volo.Abp.Identity
{
return _userAppService.FindByEmailAsync(email);
}
public Task ChangePasswordAsync(string currentPassword, string newPassword)
{
return _userAppService.ChangePasswordAsync(currentPassword, newPassword);
}
}
}

10
modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/ProfileController.cs

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
@ -27,5 +24,10 @@ namespace Volo.Abp.Identity
{
return _profileAppService.UpdateAsync(input);
}
public Task ChangePasswordAsync(string currentPassword, string newPassword)
{
return _profileAppService.ChangePasswordAsync(currentPassword, newPassword);
}
}
}

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

@ -12,13 +12,14 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Shared
[BindProperty]
public ChangePasswordInfoModel ChangePasswordInfoModel { get; set; }
private readonly IIdentityUserAppService _userAppService;
private readonly IProfileAppService _profileAppService;
private readonly IStringLocalizer<IdentityResource> _localizer;
public ChangePasswordModal(IIdentityUserAppService userAppService,
public ChangePasswordModal(
IProfileAppService profileAppService,
IStringLocalizer<IdentityResource> localizer)
{
_userAppService = userAppService;
_profileAppService = profileAppService;
_localizer = localizer;
}
@ -31,8 +32,10 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Shared
throw new UserFriendlyException(_localizer.GetString("Identity.PasswordConfirmationFailed").Value);
}
await _userAppService.ChangePasswordAsync(ChangePasswordInfoModel.CurrentPassword,
ChangePasswordInfoModel.NewPassword);
await _profileAppService.ChangePasswordAsync(
ChangePasswordInfoModel.CurrentPassword,
ChangePasswordInfoModel.NewPassword
);
return NoContent();
}

Loading…
Cancel
Save