Move change password to profile service

pull/905/head
Halil ibrahim Kalkan 6 years ago
parent d9433687ab
commit dd9fbcda60

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

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

@ -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) private async Task UpdateUserByInput(IdentityUser user, IdentityUserCreateOrUpdateDtoBase input)
{ {
(await _userManager.SetEmailAsync(user, input.Email)).CheckErrors(); (await _userManager.SetEmailAsync(user, input.Email)).CheckErrors();

@ -49,5 +49,11 @@ namespace Volo.Abp.Identity
return ObjectMapper.Map<IdentityUser, ProfileDto>(user); 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();
}
} }
} }

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

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

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

Loading…
Cancel
Save