diff --git a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json index e9215d3f5a..85bd040d8c 100644 --- a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json +++ b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json @@ -53,6 +53,8 @@ "ResetPassword_Information": "Please enter your new password.", "YourPasswordIsSuccessfullyReset": "Your password is successfully reset.", "GoToTheApplication": "Go to the application", - "BackToLogin": "Back to login" + "BackToLogin": "Back to login", + "ProfileTab:Password": "Change password", + "ProfileTab:PersonalInfo": "Personal info" } } diff --git a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/tr.json b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/tr.json index bbb2ac3638..c9aff72675 100644 --- a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/tr.json +++ b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/tr.json @@ -52,6 +52,8 @@ "ResetPassword_Information": "Lütfen yeni şifrenizi belirleyin.", "YourPasswordIsSuccessfullyReset": "Şifreniz başarıyla sıfırlandı.", "GoToTheApplication": "Uygulamaya git", - "BackToLogin": "Girişe dön" + "BackToLogin": "Girişe dön", + "ProfileTab:Password": "Şifre değiştir", + "ProfileTab:PersonalInfo": "Kişisel bilgiler" } } diff --git a/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebAutomapperProfile.cs b/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebAutomapperProfile.cs index ab7ea41269..6204c20582 100644 --- a/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebAutomapperProfile.cs +++ b/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebAutomapperProfile.cs @@ -1,6 +1,7 @@ using Volo.Abp.Account.Web.Pages.Account; using Volo.Abp.Identity; using AutoMapper; +using Volo.Abp.Account.Web.Pages.Account.Components.ProfileManagementGroup.PersonalInfo; namespace Volo.Abp.Account.Web { @@ -8,7 +9,7 @@ namespace Volo.Abp.Account.Web { public AbpAccountWebAutoMapperProfile() { - CreateMap(); + CreateMap(); } } } diff --git a/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs b/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs index 10886e4c17..303963d24f 100644 --- a/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs +++ b/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs @@ -1,7 +1,10 @@ using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Account.Localization; +using Volo.Abp.Account.Web.Pages.Account; +using Volo.Abp.Account.Web.ProfileManagement; using Volo.Abp.AspNetCore.Mvc.Localization; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars; using Volo.Abp.AutoMapper; @@ -50,16 +53,38 @@ namespace Volo.Abp.Account.Web options.Contributors.Add(new AccountModuleToolbarContributor()); }); + ConfigureProfileManagementPage(); + + context.Services.AddAutoMapperObjectMapper(); + Configure(options => + { + options.AddProfile(validate: true); + }); + } + + private void ConfigureProfileManagementPage() + { Configure(options => { options.Conventions.AuthorizePage("/Account/Manage"); }); - context.Services.AddAutoMapperObjectMapper(); - Configure(options => + Configure(options => { - options.AddProfile(validate: true); + options.Contributors.Add(new AccountProfileManagementPageContributor()); }); + + Configure(options => + { + options.ScriptBundles + .Configure(typeof(ManageModel).FullName, + configuration => + { + configuration.AddFiles("/Pages/Account/Components/ProfileManagementGroup/Password/Default.js"); + configuration.AddFiles("/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.js"); + }); + }); + } } } diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/Password/AccountProfilePasswordManagementGroupViewComponent.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/Password/AccountProfilePasswordManagementGroupViewComponent.cs new file mode 100644 index 0000000000..7a0df6878b --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/Password/AccountProfilePasswordManagementGroupViewComponent.cs @@ -0,0 +1,59 @@ +using System.ComponentModel.DataAnnotations; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Auditing; +using Volo.Abp.Identity; +using Volo.Abp.Validation; + +namespace Volo.Abp.Account.Web.Pages.Account.Components.ProfileManagementGroup.Password +{ + public class AccountProfilePasswordManagementGroupViewComponent : AbpViewComponent + { + private readonly IProfileAppService _profileAppService; + + public AccountProfilePasswordManagementGroupViewComponent( + IProfileAppService profileAppService) + { + _profileAppService = profileAppService; + } + + public async Task InvokeAsync() + { + var user = await _profileAppService.GetAsync(); + + var model = new ChangePasswordInfoModel + { + HideOldPasswordInput = !user.HasPassword + }; + + return View("~/Pages/Account/Components/ProfileManagementGroup/Password/Default.cshtml", model); + } + + public class ChangePasswordInfoModel + { + [Required] + [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))] + [Display(Name = "DisplayName:CurrentPassword")] + [DataType(DataType.Password)] + [DisableAuditing] + public string CurrentPassword { get; set; } + + [Required] + [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))] + [Display(Name = "DisplayName:NewPassword")] + [DataType(DataType.Password)] + [DisableAuditing] + public string NewPassword { get; set; } + + [Required] + [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))] + [Display(Name = "DisplayName:NewPasswordConfirm")] + [DataType(DataType.Password)] + [DisableAuditing] + public string NewPasswordConfirm { get; set; } + + public bool HideOldPasswordInput { get; set; } + } + } +} diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/Password/Default.cshtml b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/Password/Default.cshtml new file mode 100644 index 0000000000..febab6d081 --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/Password/Default.cshtml @@ -0,0 +1,17 @@ +@using Volo.Abp.Account.Localization +@using Volo.Abp.Users +@using Microsoft.AspNetCore.Mvc.Localization +@inject IHtmlLocalizer L +@inject ICurrentUser CurrentUser +@model Volo.Abp.Account.Web.Pages.Account.Components.ProfileManagementGroup.Password.AccountProfilePasswordManagementGroupViewComponent.ChangePasswordInfoModel + +

@L["ChangePassword"]


+
+ @if (!Model.HideOldPasswordInput) + { + + } + + + + diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/Password/Default.js b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/Password/Default.js new file mode 100644 index 0000000000..ef38f68466 --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/Password/Default.js @@ -0,0 +1,31 @@ +(function ($) { + $(function () { + var l = abp.localization.getResource("AbpAccount"); + + $('#ChangePasswordForm').submit(function (e) { + e.preventDefault(); + + if (!$('#ChangePasswordForm').valid()) { + return false; + } + + var input = $('#ChangePasswordForm').serializeFormToObject(); + + if ( + input.newPassword != input.newPasswordConfirm || + input.newPassword == '' + ) { + abp.message.error(l('NewPasswordConfirmFailed')); + return; + } + + if (input.currentPassword && input.currentPassword == ''){ + return; + } + + volo.abp.identity.profile.changePassword(input).then(function (result) { + abp.message.success(l('PasswordChanged')); + }); + }); + }); +})(jQuery); diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/AccountProfilePersonalInfoManagementGroupViewComponent.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/AccountProfilePersonalInfoManagementGroupViewComponent.cs new file mode 100644 index 0000000000..512d646ff2 --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/AccountProfilePersonalInfoManagementGroupViewComponent.cs @@ -0,0 +1,56 @@ +using System.ComponentModel.DataAnnotations; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Identity; +using Volo.Abp.Validation; + +namespace Volo.Abp.Account.Web.Pages.Account.Components.ProfileManagementGroup.PersonalInfo +{ + public class AccountProfilePersonalInfoManagementGroupViewComponent : AbpViewComponent + { + private readonly IProfileAppService _profileAppService; + + public AccountProfilePersonalInfoManagementGroupViewComponent( + IProfileAppService profileAppService) + { + _profileAppService = profileAppService; + + ObjectMapperContext = typeof(AbpAccountWebModule); + } + + public async Task InvokeAsync() + { + var user = await _profileAppService.GetAsync(); + + var model = ObjectMapper.Map(user); + + return View("~/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.cshtml", model); + } + + public class PersonalInfoModel + { + [Required] + [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxUserNameLength))] + [Display(Name = "DisplayName:UserName")] + public string UserName { get; set; } + + [Required] + [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))] + [Display(Name = "DisplayName:Email")] + public string Email { get; set; } + + [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxNameLength))] + [Display(Name = "DisplayName:Name")] + public string Name { get; set; } + + [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxSurnameLength))] + [Display(Name = "DisplayName:Surname")] + public string Surname { get; set; } + + [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPhoneNumberLength))] + [Display(Name = "DisplayName:PhoneNumber")] + public string PhoneNumber { get; set; } + } + } +} diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.cshtml b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.cshtml new file mode 100644 index 0000000000..33ca670b0c --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.cshtml @@ -0,0 +1,39 @@ +@using Volo.Abp.Account.Localization +@using Volo.Abp.Users +@using Microsoft.AspNetCore.Mvc.Localization +@using Volo.Abp.AspNetCore.Mvc.UI.Theming +@using Volo.Abp.Identity.Settings +@using Volo.Abp.Settings +@inject IHtmlLocalizer L +@inject ICurrentUser CurrentUser +@inject ISettingProvider SettingManager +@inject IThemeManager ThemeManager +@model Volo.Abp.Account.Web.Pages.Account.Components.ProfileManagementGroup.PersonalInfo.AccountProfilePersonalInfoManagementGroupViewComponent.PersonalInfoModel +@{ + 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); +} + +

@L["PersonalSettings"]


+
+ + + + + + + + + + + + + + + + + + diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.js b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.js new file mode 100644 index 0000000000..6f5642d07d --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.js @@ -0,0 +1,19 @@ +(function ($) { + $(function () { + var l = abp.localization.getResource("AbpAccount"); + + $('#PersonalSettingsForm').submit(function (e) { + e.preventDefault(); + + if (!$('#PersonalSettingsForm').valid()) { + return false; + } + + var input = $('#PersonalSettingsForm').serializeFormToObject(); + + volo.abp.identity.profile.update(input).then(function (result) { + abp.notify.success(l('PersonalSettingsSaved')); + }); + }); + }); +})(jQuery); diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml index 23350442b2..ff6262f3ec 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml @@ -2,66 +2,33 @@ @using Microsoft.AspNetCore.Mvc.Localization @using Volo.Abp.Account.Localization @using Volo.Abp.Account.Web.Pages.Account -@using Volo.Abp.Identity.Settings -@using Volo.Abp.Settings @using Volo.Abp.AspNetCore.Mvc.UI.Theming -@inject ISettingProvider SettingManager @inject IThemeManager ThemeManager @inject IHtmlLocalizer L @model ManageModel @{ 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 { - - - + } - - - - @if (!Model.DisablePasswordChange) - { - -

@L["ChangePassword"].Value


-
- @if (!Model.HideOldPasswordInput) - { - - } - - - - -
- } - -

@L["PersonalSettings"].Value


-
- - - - - - - - - - - - - - - - - -
-
-
-
+
+ + + + @foreach (var group in Model.ProfileManagementPageCreationContext.Groups) + { + +

@group.DisplayName

+
+ @await Component.InvokeAsync(group.ComponentType, new + { + parameter = group.Parameter + }) +
+ } +
+
+
+
diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml.cs index db51f9890c..f7b08eb6c4 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml.cs @@ -2,35 +2,31 @@ using System.Threading.Tasks; using Volo.Abp.Identity; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Options; +using Volo.Abp.Account.Web.ProfileManagement; using Volo.Abp.Validation; namespace Volo.Abp.Account.Web.Pages.Account { public class ManageModel : AccountPageModel { - public ChangePasswordInfoModel ChangePasswordInfoModel { get; set; } + public ProfileManagementPageCreationContext ProfileManagementPageCreationContext { get; private set; } - public PersonalSettingsInfoModel PersonalSettingsInfoModel { get; set; } + protected ProfileManagementPageOptions Options { get; } - public bool DisablePasswordChange { get; set; } - - public bool HideOldPasswordInput { get; set; } - - protected IProfileAppService ProfileAppService { get; } - - public ManageModel(IProfileAppService profileAppService) + public ManageModel(IOptions options) { - ProfileAppService = profileAppService; + Options = options.Value; } public virtual async Task OnGetAsync() { - var user = await ProfileAppService.GetAsync(); - - PersonalSettingsInfoModel = ObjectMapper.Map(user); + ProfileManagementPageCreationContext = new ProfileManagementPageCreationContext(ServiceProvider); - DisablePasswordChange = user.IsExternal; - HideOldPasswordInput = !user.HasPassword; + foreach (var contributor in Options.Contributors) + { + await contributor.ConfigureAsync(ProfileManagementPageCreationContext); + } return Page(); } @@ -40,50 +36,4 @@ namespace Volo.Abp.Account.Web.Pages.Account return Task.FromResult(Page()); } } - - public class ChangePasswordInfoModel - { - [Required] - [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))] - [Display(Name = "DisplayName:CurrentPassword")] - [DataType(DataType.Password)] - public string CurrentPassword { get; set; } - - [Required] - [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))] - [Display(Name = "DisplayName:NewPassword")] - [DataType(DataType.Password)] - public string NewPassword { get; set; } - - [Required] - [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPasswordLength))] - [Display(Name = "DisplayName:NewPasswordConfirm")] - [DataType(DataType.Password)] - public string NewPasswordConfirm { get; set; } - } - - public class PersonalSettingsInfoModel - { - [Required] - [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxUserNameLength))] - [Display(Name = "DisplayName:UserName")] - public string UserName { get; set; } - - [Required] - [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))] - [Display(Name = "DisplayName:Email")] - public string Email { get; set; } - - [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxNameLength))] - [Display(Name = "DisplayName:Name")] - public string Name { get; set; } - - [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxSurnameLength))] - [Display(Name = "DisplayName:Surname")] - public string Surname { get; set; } - - [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxPhoneNumberLength))] - [Display(Name = "DisplayName:PhoneNumber")] - public string PhoneNumber { get; set; } - } } diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.js b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.js deleted file mode 100644 index 3c7c4148e8..0000000000 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.js +++ /dev/null @@ -1,47 +0,0 @@ -(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.newPassword == '' - ) { - abp.message.error(l('NewPasswordConfirmFailed')); - return; - } - - if (input.currentPassword && 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); diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs index a8ec942084..0560197cd3 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs @@ -18,7 +18,6 @@ namespace Volo.Abp.Account.Web.Pages.Account { public class RegisterModel : AccountPageModel { - protected IAccountAppService AccountAppService { get; } [BindProperty(SupportsGet = true)] public string ReturnUrl { get; set; } diff --git a/modules/account/src/Volo.Abp.Account.Web/ProfileManagement/AccountProfileManagementPageContributor.cs b/modules/account/src/Volo.Abp.Account.Web/ProfileManagement/AccountProfileManagementPageContributor.cs new file mode 100644 index 0000000000..3f2a11ac86 --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web/ProfileManagement/AccountProfileManagementPageContributor.cs @@ -0,0 +1,48 @@ +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Localization; +using Volo.Abp.Account.Localization; +using Volo.Abp.Account.Web.Pages.Account.Components.ProfileManagementGroup.Password; +using Volo.Abp.Account.Web.Pages.Account.Components.ProfileManagementGroup.PersonalInfo; +using Volo.Abp.Identity; +using Volo.Abp.Users; + +namespace Volo.Abp.Account.Web.ProfileManagement +{ + public class AccountProfileManagementPageContributor : IProfileManagementPageContributor + { + public async Task ConfigureAsync(ProfileManagementPageCreationContext context) + { + var l = context.ServiceProvider.GetRequiredService>(); + + if (await IsPasswordChangeEnabled(context)) + { + context.Groups.Add( + new ProfileManagementPageGroup( + "Volo.Abp.Account.Password", + l["ProfileTab:Password"], + typeof(AccountProfilePasswordManagementGroupViewComponent) + ) + ); + } + + context.Groups.Add( + new ProfileManagementPageGroup( + "Volo.Abp.Account.PersonalInfo", + l["ProfileTab:PersonalInfo"], + typeof(AccountProfilePersonalInfoManagementGroupViewComponent) + ) + ); + } + + protected virtual async Task IsPasswordChangeEnabled(ProfileManagementPageCreationContext context) + { + var userManager = context.ServiceProvider.GetRequiredService(); + var currentUser = context.ServiceProvider.GetRequiredService(); + + var user = await userManager.GetByIdAsync(currentUser.GetId()); + + return !user.IsExternal; + } + } +} diff --git a/modules/account/src/Volo.Abp.Account.Web/ProfileManagement/IProfileManagementPageContributor.cs b/modules/account/src/Volo.Abp.Account.Web/ProfileManagement/IProfileManagementPageContributor.cs new file mode 100644 index 0000000000..d65cc1fb0d --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web/ProfileManagement/IProfileManagementPageContributor.cs @@ -0,0 +1,9 @@ +using System.Threading.Tasks; + + namespace Volo.Abp.Account.Web.ProfileManagement +{ + public interface IProfileManagementPageContributor + { + Task ConfigureAsync(ProfileManagementPageCreationContext context); + } +} diff --git a/modules/account/src/Volo.Abp.Account.Web/ProfileManagement/ProfileManagementPageCreationContext.cs b/modules/account/src/Volo.Abp.Account.Web/ProfileManagement/ProfileManagementPageCreationContext.cs new file mode 100644 index 0000000000..f3a9a80de7 --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web/ProfileManagement/ProfileManagementPageCreationContext.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +namespace Volo.Abp.Account.Web.ProfileManagement +{ + public class ProfileManagementPageCreationContext + { + public IServiceProvider ServiceProvider { get; } + + public List Groups { get; } + + public ProfileManagementPageCreationContext(IServiceProvider serviceProvider) + { + ServiceProvider = serviceProvider; + + Groups = new List(); + } + } +} diff --git a/modules/account/src/Volo.Abp.Account.Web/ProfileManagement/ProfileManagementPageGroup.cs b/modules/account/src/Volo.Abp.Account.Web/ProfileManagement/ProfileManagementPageGroup.cs new file mode 100644 index 0000000000..ff491107aa --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web/ProfileManagement/ProfileManagementPageGroup.cs @@ -0,0 +1,39 @@ +using System; +using JetBrains.Annotations; + +namespace Volo.Abp.Account.Web.ProfileManagement +{ + public class ProfileManagementPageGroup + { + public string Id + { + get => _id; + set => _id = Check.NotNullOrWhiteSpace(value, nameof(Id)); + } + private string _id; + + public string DisplayName + { + get => _displayName; + set => _displayName = Check.NotNullOrWhiteSpace(value, nameof(DisplayName)); + } + private string _displayName; + + public Type ComponentType + { + get => _componentType; + set => _componentType = Check.NotNull(value, nameof(ComponentType)); + } + private Type _componentType; + + public object Parameter { get; set; } + + public ProfileManagementPageGroup([NotNull] string id, [NotNull] string displayName, [NotNull] Type componentType, object parameter = null) + { + Id = id; + DisplayName = displayName; + ComponentType = componentType; + Parameter = parameter; + } + } +} diff --git a/modules/account/src/Volo.Abp.Account.Web/ProfileManagement/ProfileManagementPageOptions.cs b/modules/account/src/Volo.Abp.Account.Web/ProfileManagement/ProfileManagementPageOptions.cs new file mode 100644 index 0000000000..91cf0ab0c1 --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web/ProfileManagement/ProfileManagementPageOptions.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; + + namespace Volo.Abp.Account.Web.ProfileManagement +{ + public class ProfileManagementPageOptions + { + public List Contributors { get; } + + public ProfileManagementPageOptions() + { + Contributors = new List(); + } + } +}