mirror of https://github.com/abpframework/abp.git
19 changed files with 185 additions and 21 deletions
@ -0,0 +1,20 @@ |
|||
@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> |
|||
@ -0,0 +1,61 @@ |
|||
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 IIdentityUserAppService _userAppService; |
|||
private readonly IStringLocalizer<IdentityResource> _localizer; |
|||
|
|||
public ChangePasswordModal(IIdentityUserAppService userAppService, |
|||
IStringLocalizer<IdentityResource> localizer) |
|||
{ |
|||
_userAppService = userAppService; |
|||
_localizer = localizer; |
|||
} |
|||
|
|||
public async Task<IActionResult> OnPostAsync() |
|||
{ |
|||
ValidateModel(); |
|||
|
|||
if (ChangePasswordInfoModel.NewPassword != ChangePasswordInfoModel.NewPasswordConfirm) |
|||
{ |
|||
throw new UserFriendlyException(_localizer.GetString("Identity.PasswordConfirmationFailed").Value); |
|||
} |
|||
|
|||
await _userAppService.ChangePasswordAsync(ChangePasswordInfoModel.CurrentPassword, |
|||
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; } |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
(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); |
|||
Loading…
Reference in new issue