From c3ab0b8f82aaebd7d3071eb164f9fe997c2d5abd Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Wed, 7 Nov 2018 14:08:04 +0300 Subject: [PATCH] Personal settings #309 --- .../Localization/Resources/AbpUi/en.json | 3 +- .../Localization/Resources/AbpUi/tr.json | 3 +- .../AbpAccountUserMenuContributor.cs | 2 + .../Abp/Identity/IIdentityUserAppService.cs | 2 + .../IdentityUserCreateOrUpdateDtoBase.cs | 6 ++ .../Volo/Abp/Identity/IdentityUserDto.cs | 6 +- .../Abp/Identity/UpdatePersonalSettingsDto.cs | 16 +++++ .../Abp/Identity/IdentityUserAppService.cs | 20 +++++- .../Volo/Abp/Identity/IdentityUserConsts.cs | 4 ++ .../Volo/Abp/Identity/IdentityUser.cs | 13 +++- .../Volo/Abp/Identity/IdentityUserManager.cs | 12 ++++ .../Abp/Identity/IdentityUserExtensions.cs | 2 + .../Abp/Identity/IdentityUserController.cs | 5 ++ .../AbpIdentityWebAutoMapperProfile.cs | 5 ++ .../AbpIdentityWebModule.cs | 3 +- .../Resources/AbpIdentity/en.json | 7 +- .../Resources/AbpIdentity/tr.json | 7 +- .../Shared/PersonalSettingsModal.cshtml | 20 ++++++ .../Shared/PersonalSettingsModal.cshtml.cs | 64 +++++++++++++++++++ .../Shared/personal-settings-modal.js | 18 ++++++ .../Pages/Identity/Users/CreateModal.cshtml | 2 + .../Identity/Users/CreateModal.cshtml.cs | 6 ++ .../Pages/Identity/Users/EditModal.cshtml | 14 ++-- .../Pages/Identity/Users/EditModal.cshtml.cs | 6 ++ .../Volo/Abp/Users/IUserData.cs | 4 ++ .../Volo/Abp/Users/UserData.cs | 8 +++ .../Volo/Abp/Users/AbpUserConsts.cs | 4 ++ .../Volo/Abp/Users/AbpUserExtensions.cs | 2 + .../Volo/Abp/Users/IUser.cs | 6 ++ ...bpUsersDbContextModelCreatingExtensions.cs | 2 + 30 files changed, 258 insertions(+), 14 deletions(-) create mode 100644 modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/UpdatePersonalSettingsDto.cs create mode 100644 modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/PersonalSettingsModal.cshtml create mode 100644 modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/PersonalSettingsModal.cshtml.cs create mode 100644 modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/personal-settings-modal.js diff --git a/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/en.json b/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/en.json index 9c8944176b..fa4e348f4b 100644 --- a/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/en.json +++ b/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/en.json @@ -34,6 +34,7 @@ "PagerPrevious": "Previous", "PagerInfo": "Showing {0} to {1} of {2} entries.", "DatatableActionDropdownDefaultText": "Actions", - "ChangePassword": "Change password" + "ChangePassword": "Change password", + "PersonalInfo": "Personal info" } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/tr.json b/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/tr.json index f85e255058..0215dfd071 100644 --- a/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/tr.json +++ b/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/tr.json @@ -34,6 +34,7 @@ "PagerPrevious": "Önceki", "PagerInfo": "{2} kayıttan {0} ile {1} arası gösteriliyor.", "DatatableActionDropdownDefaultText": "İşlemler", - "ChangePassword": "Şifre değiştir" + "ChangePassword": "Şifre değiştir", + "PersonalInfo": "Kişisel Bilgiler" } } \ No newline at end of file diff --git a/modules/account/src/Volo.Abp.Account.Web/AbpAccountUserMenuContributor.cs b/modules/account/src/Volo.Abp.Account.Web/AbpAccountUserMenuContributor.cs index d021cbabe1..2741aabe82 100644 --- a/modules/account/src/Volo.Abp.Account.Web/AbpAccountUserMenuContributor.cs +++ b/modules/account/src/Volo.Abp.Account.Web/AbpAccountUserMenuContributor.cs @@ -24,6 +24,8 @@ namespace Volo.Abp.Account.Web context.Menu.AddItem(new ApplicationMenuItem("Account.ChangePassword", l["ChangePassword"], icon: "fa fa-key", url: "#", elementId: "abp-account-change-password")); + context.Menu.AddItem(new ApplicationMenuItem("Account.PersonalSettings", l["PersonalInfo"], icon: "fa fa-info", url: "#", elementId: "abp-account-personal-settings")); + context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000)); return Task.CompletedTask; diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityUserAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityUserAppService.cs index 39d510f2c1..711f2d2956 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityUserAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityUserAppService.cs @@ -16,6 +16,8 @@ namespace Volo.Abp.Identity Task UpdatePermissionsAsync(Guid id, UpdatePermissionsDto input); + Task UpdatePersonalSettingsAsync(UpdatePersonalSettingsDto input); + Task FindByUsernameAsync(string username); Task FindByEmailAsync(string email); diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserCreateOrUpdateDtoBase.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserCreateOrUpdateDtoBase.cs index a3461fcd90..0715d2512a 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserCreateOrUpdateDtoBase.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserCreateOrUpdateDtoBase.cs @@ -9,6 +9,12 @@ namespace Volo.Abp.Identity [StringLength(IdentityUserConsts.MaxUserNameLength)] public string UserName { get; set; } + [StringLength(IdentityUserConsts.MaxNameLength)] + public string Name { get; set; } + + [StringLength(IdentityUserConsts.MaxSurnameLength)] + public string Surname { get; set; } + [Required] [EmailAddress] [StringLength(IdentityUserConsts.MaxEmailLength)] diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserDto.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserDto.cs index 893d2ea710..bc28a79f8e 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserDto.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserDto.cs @@ -4,12 +4,16 @@ using Volo.Abp.MultiTenancy; namespace Volo.Abp.Identity { - public class IdentityUserDto : EntityDto, IMultiTenant + public class IdentityUserDto : FullAuditedEntityDto, IMultiTenant { public Guid? TenantId { get; set; } public string UserName { get; set; } + public string Name { get; set; } + + public string Surname { get; set; } + public string Email { get; set; } public bool EmailConfirmed { get; set; } diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/UpdatePersonalSettingsDto.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/UpdatePersonalSettingsDto.cs new file mode 100644 index 0000000000..943cb4181f --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/UpdatePersonalSettingsDto.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; + +namespace Volo.Abp.Identity +{ + public class UpdatePersonalSettingsDto + { + [StringLength(IdentityUserConsts.MaxNameLength)] + public string Name { get; set; } + + [StringLength(IdentityUserConsts.MaxSurnameLength)] + public string Surname { get; set; } + + [StringLength(IdentityUserConsts.MaxPhoneNumberLength)] + public string PhoneNumber { get; set; } + } +} \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs index c20c4109f3..b26105a2bd 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Security.Authentication; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; @@ -115,6 +116,23 @@ namespace Volo.Abp.Identity await _permissionAppServiceHelper.UpdateAsync(UserPermissionValueProvider.ProviderName, id.ToString(), input); } + public async Task UpdatePersonalSettingsAsync(UpdatePersonalSettingsDto input) + { + if (!CurrentUser.Id.HasValue) + { + throw new AuthenticationException(); + } + + var user = await _userManager.GetByIdAsync(CurrentUser.Id.Value); + + await _userManager.SetPersonalSettingsAsync(user, input.Name, input.Surname, input.PhoneNumber); + + (await _userManager.UpdateAsync(user)).CheckErrors(); + await CurrentUnitOfWork.SaveChangesAsync(); + + return ObjectMapper.Map(user); + } + [Authorize(IdentityPermissions.Users.Default)] public async Task FindByUsernameAsync(string username) { @@ -145,7 +163,7 @@ namespace Volo.Abp.Identity private async Task UpdateUserByInput(IdentityUser user, IdentityUserCreateOrUpdateDtoBase input) { (await _userManager.SetEmailAsync(user, input.Email)).CheckErrors(); - (await _userManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors(); + (await _userManager.SetPersonalSettingsAsync(user,input.Name,input.Surname, input.PhoneNumber)).CheckErrors(); (await _userManager.SetTwoFactorEnabledAsync(user, input.TwoFactorEnabled)).CheckErrors(); (await _userManager.SetLockoutEnabledAsync(user, input.LockoutEnabled)).CheckErrors(); diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserConsts.cs b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserConsts.cs index c41c63280d..f56a59e967 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserConsts.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserConsts.cs @@ -6,6 +6,10 @@ namespace Volo.Abp.Identity { public const int MaxUserNameLength = AbpUserConsts.MaxUserNameLength; + public const int MaxNameLength = AbpUserConsts.MaxNameLength; + + public const int MaxSurnameLength = AbpUserConsts.MaxSurnameLength; + public const int MaxNormalizedUserNameLength = MaxUserNameLength; public const int MaxEmailLength = AbpUserConsts.MaxEmailLength; diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUser.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUser.cs index a381ec66ba..48e68e3413 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUser.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUser.cs @@ -8,12 +8,13 @@ using Microsoft.AspNetCore.Identity; using Volo.Abp.Auditing; using Volo.Abp.Data; using Volo.Abp.Domain.Entities; +using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Guids; using Volo.Abp.Users; namespace Volo.Abp.Identity { - public class IdentityUser : AggregateRoot, IHasConcurrencyStamp, IUser, IHasExtraProperties + public class IdentityUser : FullAuditedAggregateRoot, IHasConcurrencyStamp, IUser, IHasExtraProperties { public virtual Guid? TenantId { get; protected set; } @@ -28,6 +29,16 @@ namespace Volo.Abp.Identity [DisableAuditing] public virtual string NormalizedUserName { get; protected internal set; } + /// + /// Gets or sets the Name for the user. + /// + public virtual string Name { get; protected internal set; } + + /// + /// Gets or sets the Surame for the user. + /// + public virtual string Surname { get; protected internal set; } + /// /// Gets or sets the email address for this user. /// diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs index dc4b2fe4b2..75ca563372 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs @@ -75,5 +75,17 @@ namespace Volo.Abp.Identity return IdentityResult.Success; } + + public async Task SetPersonalSettingsAsync([NotNull] IdentityUser user, [CanBeNull] string name, [CanBeNull] string surname, [CanBeNull] string phoneNumber) + { + Check.NotNull(user, nameof(user)); + + user.Name = name; + user.Surname = surname; + + (await SetPhoneNumberAsync(user, phoneNumber)).CheckErrors(); + + return IdentityResult.Success; + } } } diff --git a/modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/IdentityUserExtensions.cs b/modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/IdentityUserExtensions.cs index 3535bb5904..bdb1e9044e 100644 --- a/modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/IdentityUserExtensions.cs +++ b/modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/IdentityUserExtensions.cs @@ -10,6 +10,8 @@ namespace Volo.Abp.Identity user.Id, user.UserName, user.Email, + user.Name, + user.Surname, user.EmailConfirmed, user.PhoneNumber, user.PhoneNumberConfirmed, diff --git a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs index 2d6ad778ae..8ed7bec3f5 100644 --- a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs +++ b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs @@ -64,6 +64,11 @@ namespace Volo.Abp.Identity return _userAppService.UpdatePermissionsAsync(id, input); } + public virtual Task UpdatePersonalSettingsAsync(UpdatePersonalSettingsDto input) + { + return _userAppService.UpdatePersonalSettingsAsync(input); + } + [HttpGet] public virtual Task FindByUsernameAsync(string username) { diff --git a/modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs b/modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs index c8651d8e88..38c607ff48 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs @@ -1,5 +1,6 @@ using AutoMapper; using Volo.Abp.Identity.Web.Pages.Identity.Roles; +using Volo.Abp.Identity.Web.Pages.Identity.Shared; using CreateUserModalModel = Volo.Abp.Identity.Web.Pages.Identity.Users.CreateModalModel; using EditUserModalModel = Volo.Abp.Identity.Web.Pages.Identity.Users.EditModalModel; @@ -31,6 +32,10 @@ namespace Volo.Abp.Identity.Web CreateMap() .ForMember(dest => dest.IsAssigned, opt => opt.Ignore()); + + CreateMap(); + + CreateMap(); } private void CreateRoleMappings() diff --git a/modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs b/modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs index f898ad3ea3..934d0460b2 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs @@ -75,7 +75,8 @@ namespace Volo.Abp.Identity.Web options .ScriptBundles .Get(StandardBundles.Scripts.Global) - .AddFiles("/Pages/Identity/Shared/change-password-modal.js"); + .AddFiles("/Pages/Identity/Shared/change-password-modal.js") + .AddFiles("/Pages/Identity/Shared/personal-settings-modal.js"); }); } } diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Localization/Resources/AbpIdentity/en.json b/modules/identity/src/Volo.Abp.Identity.Web/Localization/Resources/AbpIdentity/en.json index e63e8fb4b2..a7370325e4 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Localization/Resources/AbpIdentity/en.json +++ b/modules/identity/src/Volo.Abp.Identity.Web/Localization/Resources/AbpIdentity/en.json @@ -10,10 +10,14 @@ "UserInformations": "User informations", "Roles": "Roles", "Password": "Password", + "PersonalInfo": "Personal Info", + "PersonalSettings": "Personal settings", "UserDeletionConfirmationMessage": "User '{0}' will be deleted. Do you confirm that?", "RoleDeletionConfirmationMessage": "Role '{0}' will be deleted. Do you confirm that?", "DisplayName:RoleName": "Role name", "DisplayName:UserName": "User name", + "DisplayName:Name": "Name", + "DisplayName:Surname": "Surname", "DisplayName:Password": "Password", "DisplayName:EmailAddress": "Email address", "DisplayName:PhoneNumber": "Phone number", @@ -26,6 +30,7 @@ "DisplayName:CurrentPassword": "Current password", "DisplayName:NewPassword": "New password", "DisplayName:NewPasswordConfirm": "Confirm new password", - "PasswordChangedMessage": "Your password has been changed successfully." + "PasswordChangedMessage": "Your password has been changed successfully.", + "PersonalSettingsSavedMessage": "Your personal settings has been saved successfully." } } \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Localization/Resources/AbpIdentity/tr.json b/modules/identity/src/Volo.Abp.Identity.Web/Localization/Resources/AbpIdentity/tr.json index 7484851424..b6806008b8 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Localization/Resources/AbpIdentity/tr.json +++ b/modules/identity/src/Volo.Abp.Identity.Web/Localization/Resources/AbpIdentity/tr.json @@ -10,10 +10,14 @@ "UserInformations": "Kullanıcı bilgileri", "Roles": "Roller", "Password": "Şifre", + "PersonalInfo": "Kişisel bilgi", + "PersonalSettings": "Kişisel Ayarlar", "UserDeletionConfirmationMessage": "{0} kullanıcısı silinecektir. Onaylıyor musunuz?", "RoleDeletionConfirmationMessage": "'{0}' rolü silinecektir. Onaylıyor musunuz?", "DisplayName:RoleName": "Rol adı", "DisplayName:UserName": "Kullanıcı adı", + "DisplayName:Name": "Adı", + "DisplayName:Surname": "Soyadı", "DisplayName:Password": "Şifre", "DisplayName:EmailAddress": "E-posta adresi", "DisplayName:PhoneNumber": "Telefon numarası", @@ -26,6 +30,7 @@ "DisplayName:CurrentPassword": "Mevcut şifre", "DisplayName:NewPassword": "Yeni şifre", "DisplayName:NewPasswordConfirm": "Yeni şifre (tekrar)", - "PasswordChangedMessage": "Şifreniz başarıyla değiştirildi." + "PasswordChangedMessage": "Şifreniz başarıyla değiştirildi.", + "PersonalSettingsSavedMessage": "Kişisel bilgileriniz başarıyla kaydedildi." } } \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/PersonalSettingsModal.cshtml b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/PersonalSettingsModal.cshtml new file mode 100644 index 0000000000..e6d828dd39 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/PersonalSettingsModal.cshtml @@ -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 PersonalSettingsModal +@inject IHtmlLocalizer L +@{ + Layout = null; +} + + + + + + + + + + \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/PersonalSettingsModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/PersonalSettingsModal.cshtml.cs new file mode 100644 index 0000000000..7dcc2f2273 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/PersonalSettingsModal.cshtml.cs @@ -0,0 +1,64 @@ +using System.ComponentModel.DataAnnotations; +using System.Security.Authentication; +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 PersonalSettingsModal : AbpPageModel + { + [BindProperty] + public PersonalSettingsInfoModel PersonalSettingsInfoModel { get; set; } + + private readonly IIdentityUserAppService _userAppService; + + public PersonalSettingsModal(IIdentityUserAppService userAppService) + { + _userAppService = userAppService; + } + + public async Task OnGetAsync() + { + if (!CurrentUser.Id.HasValue) + { + throw new AuthenticationException(); + } + + var user = await _userAppService.GetAsync(CurrentUser.Id.Value); + + PersonalSettingsInfoModel = ObjectMapper.Map(user); + } + + public async Task OnPostAsync() + { + ValidateModel(); + + var updateDto = ObjectMapper.Map(PersonalSettingsInfoModel); + + await _userAppService.UpdatePersonalSettingsAsync(updateDto); + + return NoContent(); + } + } + + public class PersonalSettingsInfoModel + { + [Required] + [StringLength(IdentityUserConsts.MaxNameLength)] + [Display(Name = "DisplayName:Name")] + public string Name { get; set; } + + [Required] + [StringLength(IdentityUserConsts.MaxSurnameLength)] + [Display(Name = "DisplayName:Surname")] + public string Surname { get; set; } + + [Required] + [StringLength(IdentityUserConsts.MaxPhoneNumberLength)] + [Display(Name = "DisplayName:PhoneNumber")] + public string PhoneNumber { get; set; } + } +} \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/personal-settings-modal.js b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/personal-settings-modal.js new file mode 100644 index 0000000000..36cd526a29 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/personal-settings-modal.js @@ -0,0 +1,18 @@ +(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); diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml index 448d5c5633..ed45747c0c 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml @@ -15,6 +15,8 @@ @* TODO: Can we use dynamic form? *@ + + diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs index 5de2b3d1e3..21432e941d 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs @@ -51,6 +51,12 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users [StringLength(IdentityUserConsts.MaxUserNameLength)] public string UserName { get; set; } + [StringLength(IdentityUserConsts.MaxNameLength)] + public string Name { get; set; } + + [StringLength(IdentityUserConsts.MaxSurnameLength)] + public string Surname { get; set; } + [Required] [StringLength(IdentityUserConsts.MaxPasswordLength)] [DataType(DataType.Password)] diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml index 639918d8ad..afa0df85ed 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml @@ -14,12 +14,14 @@ @* TODO: Can we use dynamic form? *@ - - - - - - + + + + + + + + @for (var i = 0; i < Model.Roles.Length; i++) diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs index c9bac5c792..25615aca94 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs @@ -63,6 +63,12 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users [StringLength(IdentityUserConsts.MaxUserNameLength)] public string UserName { get; set; } + [StringLength(IdentityUserConsts.MaxNameLength)] + public string Name { get; set; } + + [StringLength(IdentityUserConsts.MaxSurnameLength)] + public string Surname { get; set; } + [Required] [EmailAddress] [StringLength(IdentityUserConsts.MaxEmailLength)] diff --git a/modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Users/IUserData.cs b/modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Users/IUserData.cs index e7c0d8dab7..f4f2874c7f 100644 --- a/modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Users/IUserData.cs +++ b/modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Users/IUserData.cs @@ -11,6 +11,10 @@ namespace Volo.Abp.Users string UserName { get; } + string Name { get; } + + string Surname { get; } + [CanBeNull] string Email { get; } diff --git a/modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Users/UserData.cs b/modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Users/UserData.cs index 7ed587cb9c..be70f20047 100644 --- a/modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Users/UserData.cs +++ b/modules/users/src/Volo.Abp.Users.Abstractions/Volo/Abp/Users/UserData.cs @@ -9,6 +9,10 @@ namespace Volo.Abp.Users public string UserName { get; set; } + public string Name { get; set; } + + public string Surname { get; set; } + public string Email { get; set; } public bool EmailConfirmed { get; set; } @@ -28,6 +32,8 @@ namespace Volo.Abp.Users Guid id, [NotNull] string userName, [CanBeNull] string email = null, + [CanBeNull] string name = null, + [CanBeNull] string surname = null, bool emailConfirmed = false, [CanBeNull] string phoneNumber = null, bool phoneNumberConfirmed = false, @@ -36,6 +42,8 @@ namespace Volo.Abp.Users Id = id; UserName = userName; Email = email; + Name = name; + Surname = surname; EmailConfirmed = emailConfirmed; PhoneNumber = phoneNumber; PhoneNumberConfirmed = phoneNumberConfirmed; diff --git a/modules/users/src/Volo.Abp.Users.Domain.Shared/Volo/Abp/Users/AbpUserConsts.cs b/modules/users/src/Volo.Abp.Users.Domain.Shared/Volo/Abp/Users/AbpUserConsts.cs index 96fecdd60e..acfce7f37b 100644 --- a/modules/users/src/Volo.Abp.Users.Domain.Shared/Volo/Abp/Users/AbpUserConsts.cs +++ b/modules/users/src/Volo.Abp.Users.Domain.Shared/Volo/Abp/Users/AbpUserConsts.cs @@ -3,6 +3,10 @@ namespace Volo.Abp.Users public class AbpUserConsts { public const int MaxUserNameLength = 256; + + public const int MaxNameLength = 64; + + public const int MaxSurnameLength = 64; public const int MaxEmailLength = 256; diff --git a/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/AbpUserExtensions.cs b/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/AbpUserExtensions.cs index 19dea86bf5..41c3c30e3c 100644 --- a/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/AbpUserExtensions.cs +++ b/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/AbpUserExtensions.cs @@ -7,6 +7,8 @@ namespace Volo.Abp.Users return new UserData( user.Id, user.UserName, + user.Name, + user.Surname, user.Email, user.EmailConfirmed, user.PhoneNumber, diff --git a/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/IUser.cs b/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/IUser.cs index 374c41a0b7..2b06e8de97 100644 --- a/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/IUser.cs +++ b/modules/users/src/Volo.Abp.Users.Domain/Volo/Abp/Users/IUser.cs @@ -12,6 +12,12 @@ namespace Volo.Abp.Users [CanBeNull] string Email { get; } + [CanBeNull] + string Name { get; } + + [CanBeNull] + string Surname { get; } + bool EmailConfirmed { get; } [CanBeNull] diff --git a/modules/users/src/Volo.Abp.Users.EntityFrameworkCore/Volo/Abp/Users/EntityFrameworkCore/AbpUsersDbContextModelCreatingExtensions.cs b/modules/users/src/Volo.Abp.Users.EntityFrameworkCore/Volo/Abp/Users/EntityFrameworkCore/AbpUsersDbContextModelCreatingExtensions.cs index 1367fc423e..108b3f4278 100644 --- a/modules/users/src/Volo.Abp.Users.EntityFrameworkCore/Volo/Abp/Users/EntityFrameworkCore/AbpUsersDbContextModelCreatingExtensions.cs +++ b/modules/users/src/Volo.Abp.Users.EntityFrameworkCore/Volo/Abp/Users/EntityFrameworkCore/AbpUsersDbContextModelCreatingExtensions.cs @@ -12,6 +12,8 @@ namespace Volo.Abp.Users.EntityFrameworkCore b.Property(u => u.TenantId).HasColumnName(nameof(IUser.TenantId)); b.Property(u => u.UserName).IsRequired().HasMaxLength(AbpUserConsts.MaxUserNameLength).HasColumnName(nameof(IUser.UserName)); b.Property(u => u.Email).HasMaxLength(AbpUserConsts.MaxEmailLength).HasColumnName(nameof(IUser.Email)); + b.Property(u => u.Name).HasMaxLength(AbpUserConsts.MaxNameLength).HasColumnName(nameof(IUser.Name)); + b.Property(u => u.Surname).HasMaxLength(AbpUserConsts.MaxSurnameLength).HasColumnName(nameof(IUser.Surname)); b.Property(u => u.EmailConfirmed).HasDefaultValue(false).HasColumnName(nameof(IUser.EmailConfirmed)); b.Property(u => u.PhoneNumber).HasMaxLength(AbpUserConsts.MaxPhoneNumberLength).HasColumnName(nameof(IUser.PhoneNumber)); b.Property(u => u.PhoneNumberConfirmed).HasDefaultValue(false).HasColumnName(nameof(IUser.PhoneNumberConfirmed));