mirror of https://github.com/abpframework/abp.git
29 changed files with 245 additions and 319 deletions
@ -0,0 +1,14 @@ |
|||||
|
using Volo.Abp.Account.Web.Pages.Account; |
||||
|
using Volo.Abp.Identity; |
||||
|
using AutoMapper; |
||||
|
|
||||
|
namespace Volo.Abp.Account.Web |
||||
|
{ |
||||
|
public class AbpAccountWebAutoMapperProfile : Profile |
||||
|
{ |
||||
|
public AbpAccountWebAutoMapperProfile() |
||||
|
{ |
||||
|
CreateMap<ProfileDto, PersonalSettingsInfoModel>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,50 @@ |
|||||
|
@page |
||||
|
@model Volo.Abp.Account.Web.Pages.Account.ManageModel |
||||
|
@using Volo.Abp.Identity.Settings |
||||
|
@using Volo.Abp.Settings |
||||
|
@using Volo.Abp.AspNetCore.Mvc.UI.Theming |
||||
|
@inject ISettingProvider SettingManager |
||||
|
@inject IThemeManager ThemeManager |
||||
|
@inherits Volo.Abp.Account.Web.Pages.Account.AccountPage |
||||
|
@{ |
||||
|
Layout = ThemeManager.CurrentTheme.GetApplicationLayout(); |
||||
|
var isUserNameUpdateEnabled = string.Equals(await SettingManager.GetOrNullAsync(IdentitySettingNames.User.IsUserNameUpdateEnabled), "true", |
||||
|
StringComparison.OrdinalIgnoreCase); |
||||
|
|
||||
|
var isEmailUpdateEnabled = string.Equals(await SettingManager.GetOrNullAsync(IdentitySettingNames.User.IsEmailUpdateEnabled), "true", |
||||
|
StringComparison.OrdinalIgnoreCase); |
||||
|
} |
||||
|
@section scripts { |
||||
|
<abp-script src="/Pages/Account/Manage.js" /> |
||||
|
} |
||||
|
|
||||
|
<abp-tabs tab-style="PillVertical"> |
||||
|
<abp-tab title="@L["ChangePassword"].Value"> |
||||
|
<abp-dynamic-form abp-model="@Model.ChangePasswordInfoModel" id="ChangePasswordForm"> |
||||
|
<abp-form-content /> |
||||
|
<abp-button type="submit" button-type="Primary" text="@L["Submit"].Value" /> |
||||
|
</abp-dynamic-form> |
||||
|
</abp-tab> |
||||
|
<abp-tab title="@L["PersonalSettings"].Value"> |
||||
|
<form method="post" id="PersonalSettingsForm"> |
||||
|
|
||||
|
<abp-input asp-for="PersonalSettingsInfoModel.UserName" readonly="!isUserNameUpdateEnabled" /> |
||||
|
|
||||
|
<abp-row> |
||||
|
<abp-column size-md="_6"> |
||||
|
<abp-input asp-for="PersonalSettingsInfoModel.Name" /> |
||||
|
</abp-column> |
||||
|
<abp-column size-md="_6"> |
||||
|
<abp-input asp-for="PersonalSettingsInfoModel.Surname" /> |
||||
|
</abp-column> |
||||
|
</abp-row> |
||||
|
|
||||
|
<abp-input asp-for="PersonalSettingsInfoModel.Email" readonly="!isEmailUpdateEnabled" /> |
||||
|
|
||||
|
<abp-input asp-for="PersonalSettingsInfoModel.PhoneNumber" /> |
||||
|
|
||||
|
<abp-button type="submit" button-type="Primary" text="@L["Submit"].Value" /> |
||||
|
</form> |
||||
|
</abp-tab> |
||||
|
|
||||
|
</abp-tabs> |
||||
@ -0,0 +1,50 @@ |
|||||
|
(function ($) { |
||||
|
|
||||
|
var l = abp.localization.getResource('AbpAccount'); |
||||
|
|
||||
|
var _profileService = volo.abp.identity.profile; |
||||
|
|
||||
|
$("#ChangePasswordForm").submit(function (e) { |
||||
|
e.preventDefault(); |
||||
|
|
||||
|
if (!$("#ChangePasswordForm").valid()) { |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
var input = $("#ChangePasswordForm").serializeFormToObject().changePasswordInfoModel; |
||||
|
|
||||
|
if (input.newPassword != input.newPasswordConfirm || input.currentPassword == '') { |
||||
|
abp.message.error(l("NewPasswordConfirmFailed")); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if (input.currentPassword == '') { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
_profileService.changePassword( |
||||
|
input |
||||
|
).then(function (result) { |
||||
|
abp.message.success(l("PasswordChanged")); |
||||
|
}); |
||||
|
|
||||
|
}); |
||||
|
|
||||
|
$("#PersonalSettingsForm").submit(function (e) { |
||||
|
e.preventDefault(); |
||||
|
|
||||
|
if (!$("#PersonalSettingsForm").valid()) { |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
var input = $("#PersonalSettingsForm").serializeFormToObject().personalSettingsInfoModel; |
||||
|
|
||||
|
_profileService.update( |
||||
|
input |
||||
|
).then(function (result) { |
||||
|
abp.notify.success(l("PersonalSettingsSaved")); |
||||
|
}); |
||||
|
|
||||
|
}); |
||||
|
|
||||
|
})(jQuery); |
||||
@ -1,7 +0,0 @@ |
|||||
namespace Volo.Abp.Identity |
|
||||
{ |
|
||||
public interface IIdentityStoreAutoSaveChanges |
|
||||
{ |
|
||||
bool AutoSaveChanges { get; set; } |
|
||||
} |
|
||||
} |
|
||||
@ -1,20 +0,0 @@ |
|||||
@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> |
|
||||
@ -1,67 +0,0 @@ |
|||||
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 IProfileAppService _profileAppService; |
|
||||
private readonly IStringLocalizer<IdentityResource> _localizer; |
|
||||
|
|
||||
public ChangePasswordModal( |
|
||||
IProfileAppService profileAppService, |
|
||||
IStringLocalizer<IdentityResource> localizer) |
|
||||
{ |
|
||||
_profileAppService = profileAppService; |
|
||||
_localizer = localizer; |
|
||||
} |
|
||||
|
|
||||
public async Task<IActionResult> OnPostAsync() |
|
||||
{ |
|
||||
ValidateModel(); |
|
||||
|
|
||||
if (ChangePasswordInfoModel.NewPassword != ChangePasswordInfoModel.NewPasswordConfirm) |
|
||||
{ |
|
||||
throw new UserFriendlyException(_localizer.GetString("Identity.PasswordConfirmationFailed").Value); |
|
||||
} |
|
||||
|
|
||||
await _profileAppService.ChangePasswordAsync( |
|
||||
new ChangePasswordInput() |
|
||||
{ |
|
||||
CurrentPassword = ChangePasswordInfoModel.CurrentPassword, |
|
||||
NewPassword = 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; } |
|
||||
} |
|
||||
} |
|
||||
@ -1,40 +0,0 @@ |
|||||
@page |
|
||||
@using Microsoft.AspNetCore.Mvc.Localization |
|
||||
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal |
|
||||
@using Volo.Abp.Identity.Localization |
|
||||
@using Volo.Abp.Identity.Settings |
|
||||
@using Volo.Abp.Identity.Web.Pages.Identity.Shared |
|
||||
@using Volo.Abp.Settings |
|
||||
@model PersonalSettingsModal |
|
||||
@inject IHtmlLocalizer<IdentityResource> L |
|
||||
@inject ISettingProvider SettingProvider |
|
||||
@{ |
|
||||
Layout = null; |
|
||||
var isUserNameUpdateEnabled = await SettingProvider.IsTrueAsync(IdentitySettingNames.User.IsUserNameUpdateEnabled); |
|
||||
var isEmailUpdateEnabled = await SettingProvider.IsTrueAsync(IdentitySettingNames.User.IsEmailUpdateEnabled); |
|
||||
} |
|
||||
|
|
||||
<form asp-page="/Identity/Shared/PersonalSettingsModal"> |
|
||||
<abp-modal> |
|
||||
<abp-modal-header title="@L["PersonalInfo"].Value"></abp-modal-header> |
|
||||
<abp-modal-body> |
|
||||
|
|
||||
<abp-input asp-for="PersonalSettingsInfoModel.UserName" readonly="!isUserNameUpdateEnabled" /> |
|
||||
|
|
||||
<abp-row> |
|
||||
<abp-column size-md="_6"> |
|
||||
<abp-input asp-for="PersonalSettingsInfoModel.Name" /> |
|
||||
</abp-column> |
|
||||
<abp-column size-md="_6"> |
|
||||
<abp-input asp-for="PersonalSettingsInfoModel.Surname" /> |
|
||||
</abp-column> |
|
||||
</abp-row> |
|
||||
|
|
||||
<abp-input asp-for="PersonalSettingsInfoModel.Email" readonly="!isEmailUpdateEnabled" /> |
|
||||
|
|
||||
<abp-input asp-for="PersonalSettingsInfoModel.PhoneNumber" /> |
|
||||
|
|
||||
</abp-modal-body> |
|
||||
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer> |
|
||||
</abp-modal> |
|
||||
</form> |
|
||||
@ -1,18 +0,0 @@ |
|||||
(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); |
|
||||
@ -1,18 +0,0 @@ |
|||||
(function ($) { |
|
||||
|
|
||||
var l = abp.localization.getResource('AbpIdentity'); |
|
||||
var _personalSettingsModal = new abp.ModalManager(abp.appPath + 'Identity/Shared/PersonalSettingsModal'); |
|
||||
|
|
||||
$(function () { |
|
||||
|
|
||||
$("#abp-account-personal-settings").click(function (e) { |
|
||||
e.preventDefault(); |
|
||||
_personalSettingsModal.open(); |
|
||||
}); |
|
||||
|
|
||||
_personalSettingsModal.onResult(function () { |
|
||||
//abp.message.success(l("PersonalSettingsSavedMessage"));
|
|
||||
}); |
|
||||
}); |
|
||||
|
|
||||
})(jQuery); |
|
||||
Loading…
Reference in new issue