diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityPermissionDefinitionProvider.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityPermissionDefinitionProvider.cs index c04bdf2c495..c7ae8c39a8b 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityPermissionDefinitionProvider.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityPermissionDefinitionProvider.cs @@ -21,6 +21,7 @@ public override void Define(IPermissionDefinitionContext context) usersPermission.AddChild(IdentityPermissions.Users.Update, L("Permission:Edit")); usersPermission.AddChild(IdentityPermissions.Users.Delete, L("Permission:Delete")); usersPermission.AddChild(IdentityPermissions.Users.ManagePermissions, L("Permission:ChangePermissions")); + usersPermission.AddChild(IdentityPermissions.Users.ManageRoles, L("Permission:ManageRoles")); identityGroup .AddPermission(IdentityPermissions.UserLookup.Default, L("Permission:UserLookup")) diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityPermissions.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityPermissions.cs index de38cedc86f..7147da73cfb 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityPermissions.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityPermissions.cs @@ -22,6 +22,7 @@ public static class Users public const string Update = Default + ".Update"; public const string Delete = Default + ".Delete"; public const string ManagePermissions = Default + ".ManagePermissions"; + public const string ManageRoles = Update + ".ManageRoles"; } public static class UserLookup 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 d20158f16e4..9219e5169af 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 @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Options; using Volo.Abp.Application.Dtos; +using Volo.Abp.Authorization.Permissions; using Volo.Abp.Data; using Volo.Abp.ObjectExtending; @@ -16,17 +17,19 @@ public class IdentityUserAppService : IdentityAppServiceBase, IIdentityUserAppSe protected IIdentityUserRepository UserRepository { get; } protected IIdentityRoleRepository RoleRepository { get; } protected IOptions IdentityOptions { get; } - + protected IPermissionChecker PermissionChecker { get; } public IdentityUserAppService( IdentityUserManager userManager, IIdentityUserRepository userRepository, IIdentityRoleRepository roleRepository, - IOptions identityOptions) + IOptions identityOptions, + IPermissionChecker permissionChecker) { UserManager = userManager; UserRepository = userRepository; RoleRepository = roleRepository; IdentityOptions = identityOptions; + PermissionChecker = permissionChecker; } //TODO: [Authorize(IdentityPermissions.Users.Default)] should go the IdentityUserAppService class. @@ -169,6 +172,7 @@ protected virtual async Task UpdateUserByInput(IdentityUser user, IdentityUserCr (await UserManager.SetEmailAsync(user, input.Email)).CheckErrors(); } + if (!string.Equals(user.PhoneNumber, input.PhoneNumber, StringComparison.InvariantCultureIgnoreCase)) { (await UserManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors(); @@ -183,7 +187,7 @@ protected virtual async Task UpdateUserByInput(IdentityUser user, IdentityUserCr user.Surname = input.Surname; (await UserManager.UpdateAsync(user)).CheckErrors(); user.SetIsActive(input.IsActive); - if (input.RoleNames != null) + if (input.RoleNames != null && await PermissionChecker.IsGrantedAsync(IdentityPermissions.Users.ManageRoles)) { (await UserManager.SetRolesAsync(user, input.RoleNames)).CheckErrors(); } diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor index 57ab80dc5e4..ea29b2ad786 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor @@ -179,7 +179,10 @@ @L["UserInformations"] - @L["Roles"] + @if (EditUserRoles != null && EditUserRoles.Any()) + { + @L["Roles"] + } @@ -258,18 +261,21 @@ - - @if (EditUserRoles != null) - { - @foreach (var role in EditUserRoles) + @if (EditUserRoles != null && EditUserRoles.Any()) + { + + @if (EditUserRoles != null) { - - - @role.Name - + @foreach (var role in EditUserRoles) + { + + + @role.Name + + } } - } - + + } @@ -286,4 +292,4 @@ @if (HasManagePermissionsPermission) { -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs index f09c1aca8ee..53fde974db7 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs @@ -4,9 +4,11 @@ using System.Threading.Tasks; using Blazorise; using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Components; using Volo.Abp.AspNetCore.Components.Web.Extensibility.EntityActions; using Volo.Abp.AspNetCore.Components.Web.Extensibility.TableColumns; using Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars; +using Volo.Abp.Authorization.Permissions; using Volo.Abp.Identity.Localization; using Volo.Abp.ObjectExtending; using Volo.Abp.PermissionManagement.Blazor.Components; @@ -43,6 +45,9 @@ public partial class UserManagement private TextRole _passwordTextRole = TextRole.Password; public bool IsEditCurrentUser { get; set; } + [Inject] + protected IPermissionChecker PermissionChecker { get; set; } + public UserManagement() { ObjectMapperContext = typeof(AbpIdentityBlazorModule); @@ -121,15 +126,19 @@ protected override async Task OpenEditModalAsync(IdentityUserDto entity) { EditModalSelectedTab = DefaultSelectedTab; IsEditCurrentUser = entity.Id == CurrentUser.Id; - var userRoleNames = (await AppService.GetRolesAsync(entity.Id)).Items.Select(r => r.Name).ToList(); - EditUserRoles = Roles.Select(x => new AssignedRoleViewModel + if (await PermissionChecker.IsGrantedAsync(IdentityPermissions.Users.ManageRoles)) { - Name = x.Name, - IsAssigned = userRoleNames.Contains(x.Name) - }).ToArray(); + var userRoleNames = (await AppService.GetRolesAsync(entity.Id)).Items.Select(r => r.Name).ToList(); + + EditUserRoles = Roles.Select(x => new AssignedRoleViewModel + { + Name = x.Name, + IsAssigned = userRoleNames.Contains(x.Name) + }).ToArray(); - ChangePasswordTextRole(TextRole.Password); + ChangePasswordTextRole(TextRole.Password); + } await base.OpenEditModalAsync(entity); } catch (Exception ex) @@ -141,8 +150,10 @@ protected override async Task OpenEditModalAsync(IdentityUserDto entity) protected override Task OnUpdatingEntityAsync() { // apply roles before saving - EditingEntity.RoleNames = EditUserRoles.Where(x => x.IsAssigned).Select(x => x.Name).ToArray(); - + if (EditUserRoles != null) + { + EditingEntity.RoleNames = EditUserRoles.Where(x => x.IsAssigned).Select(x => x.Name).ToArray(); + } return base.OnUpdatingEntityAsync(); } diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ar.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ar.json index c4879a2ec02..f64fedeacd0 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ar.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ar.json @@ -85,6 +85,7 @@ "Permission:Edit": "تحرير", "Permission:Delete": "حذف", "Permission:ChangePermissions": "تغيير الأذونات", + "Permission:ManageRoles": "إدارة الأدوار", "Permission:UserManagement": "إدارة المستخدم", "Permission:UserLookup": "بحث المستخدم", "DisplayName:Abp.Identity.Password.RequiredLength": "الطول المطلوب", @@ -127,4 +128,4 @@ "LockoutEndTime": "وقت انتهاء القفل", "FailedAccessCount": "فشل عدد الوصول" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/cs.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/cs.json index e840810bfc7..28a6d2efe7a 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/cs.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/cs.json @@ -85,6 +85,7 @@ "Permission:Edit": "Upravit", "Permission:Delete": "Smazat", "Permission:ChangePermissions": "Změnit oprávnění", + "Permission:ManageRoles": "Správa rolí", "Permission:UserManagement": "Správa uživatelů", "Permission:UserLookup": "Vyhledání uživatele", "DisplayName:Abp.Identity.Password.RequiredLength": "Požadovaná délka", @@ -127,4 +128,4 @@ "LockoutEndTime": "Čas konce uzamčení", "FailedAccessCount": "Počet neúspěšných přístupů" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/de.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/de.json index fb71884b162..2869bc563bc 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/de.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/de.json @@ -85,6 +85,7 @@ "Permission:Edit": "Bearbeiten", "Permission:Delete": "Löschen", "Permission:ChangePermissions": "Berechtigungen ändern", + "Permission:ManageRoles": "Rollen verwalten", "Permission:UserManagement": "Benutzerverwaltung", "Permission:UserLookup": "Benutzersuche", "DisplayName:Abp.Identity.Password.RequiredLength": "Erforderliche Länge", @@ -127,4 +128,4 @@ "LockoutEndTime": "Endzeit der Sperrung", "FailedAccessCount": "Anzahl der fehlgeschlagenen Zugriffe" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/el.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/el.json index e0b33da5ae6..9c1db90c916 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/el.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/el.json @@ -84,6 +84,7 @@ "Permission:Edit": "Επεξεργασία", "Permission:Delete": "Διαγραφή", "Permission:ChangePermissions": "Αλλαγές στα δικαιώματα", + "Permission:ManageRoles": "Διαχείριση ρόλων", "Permission:UserManagement": "Διαχείριση χρηστών", "Permission:UserLookup": "Αναζήτηση χρήστη", "DisplayName:Abp.Identity.Password.RequiredLength": "Απαιτούμενο μήκος", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en-GB.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en-GB.json index c3e6fb7add0..209d4a0aee9 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en-GB.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en-GB.json @@ -83,6 +83,7 @@ "Permission:Edit": "Edit", "Permission:Delete": "Delete", "Permission:ChangePermissions": "Change permissions", + "Permission:ManageRoles": "Manage roles", "Permission:UserManagement": "User management", "Permission:UserLookup": "User lookup", "Feature:IdentityGroup": "Identity", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json index f7b02802938..4347a55a002 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json @@ -85,6 +85,7 @@ "Permission:Edit": "Edit", "Permission:Delete": "Delete", "Permission:ChangePermissions": "Change permissions", + "Permission:ManageRoles": "Manage roles", "Permission:UserManagement": "User management", "Permission:UserLookup": "User lookup", "DisplayName:Abp.Identity.Password.RequiredLength": "Required length", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/es.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/es.json index ab5b43e9802..af59c54d3c9 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/es.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/es.json @@ -85,6 +85,7 @@ "Permission:Edit": "Editar", "Permission:Delete": "Borrar", "Permission:ChangePermissions": "Cambiar permisos", + "Permission:ManageRoles": "Gestionar roles", "Permission:UserManagement": "Gestión de usuarios", "Permission:UserLookup": "Busqueda de usuario", "DisplayName:Abp.Identity.Password.RequiredLength": "Longitud requerida", @@ -127,4 +128,4 @@ "LockoutEndTime": "Hora de finalización del bloqueo", "FailedAccessCount": "Recuento de acceso fallido" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fa.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fa.json index 4e6a2953173..14b99b3ec7d 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fa.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fa.json @@ -84,6 +84,7 @@ "Permission:Edit": "ویرایش", "Permission:Delete": "حذف", "Permission:ChangePermissions": "تغییر مجوزها", + "Permission:ManageRoles": "مدیریت نقشها و وظایف", "Permission:UserManagement": "مدیریت کاربر", "Permission:UserLookup": "جستجوی کاربر", "DisplayName:Abp.Identity.Password.RequiredLength": "طول مورد نیاز", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fi.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fi.json index 5ceda22c256..74d1769602e 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fi.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fi.json @@ -85,6 +85,7 @@ "Permission:Edit": "Muokkaus", "Permission:Delete": "Poisto", "Permission:ChangePermissions": "Muuta käyttöoikeuksia", + "Permission:ManageRoles": "Hallitse rooleja", "Permission:UserManagement": "Käyttäjien hallinta", "Permission:UserLookup": "Käyttäjähaku", "DisplayName:Abp.Identity.Password.RequiredLength": "Vaadittu pituus", @@ -127,4 +128,4 @@ "LockoutEndTime": "Lukituksen päättymisaika", "FailedAccessCount": "Epäonnistuneet käyttöoikeudet" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fr.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fr.json index 7eee5a90af3..ce23db8ac01 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fr.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/fr.json @@ -85,6 +85,7 @@ "Permission:Edit": "Modifier", "Permission:Delete": "Supprimer", "Permission:ChangePermissions": "Modifier les autorisations", + "Permission:ManageRoles": "Gérer les rôles", "Permission:UserManagement": "Gestion des utilisateurs", "Permission:UserLookup": "Recherche utilisateur", "DisplayName:Abp.Identity.Password.RequiredLength": "Longueur requise", @@ -127,4 +128,4 @@ "LockoutEndTime": "Heure de fin du verrouillage", "FailedAccessCount": "Nombre d'accès ayant échoué" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hi.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hi.json index 6e1d49559c2..6be48c96ae0 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hi.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hi.json @@ -85,6 +85,7 @@ "Permission:Edit": "संपादित करें", "Permission:Delete": "हटाएं", "Permission:ChangePermissions": "अनुमतियाँ बदलें", + "Permission:ManageRoles": "भूमिकाएँ प्रबंधित करें", "Permission:UserManagement": "उपयोगकर्ता प्रबंधन", "Permission:UserLookup": "उपयोगकर्ता की खोज", "DisplayName:Abp.Identity.Password.RequiredLength": "आवश्यक लंबाई", @@ -127,4 +128,4 @@ "LockoutEndTime": "तालाबंदी समाप्ति समय", "FailedAccessCount": "विफल पहुंच गणना" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hr.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hr.json index c1ff5f1ebc1..edf6d406372 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hr.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hr.json @@ -85,6 +85,7 @@ "Permission:Edit": "Uredi", "Permission:Delete": "Izbrisati", "Permission:ChangePermissions": "Promjena dopuštenja", + "Permission:ManageRoles": "Upravljanje ulogama", "Permission:UserManagement": "Upravljanje korisnicima", "Permission:UserLookup": "Traženje korisnika", "DisplayName:Abp.Identity.Password.RequiredLength": "Potrebna dužina", @@ -127,4 +128,4 @@ "LockoutEndTime": "Vrijeme završetka zaključavanja", "FailedAccessCount": "Broj neuspjelih pristupa" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hu.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hu.json index c4858f3c112..d4d357a5ce5 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hu.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/hu.json @@ -85,6 +85,7 @@ "Permission:Edit": "Szerkesztés", "Permission:Delete": "Törlés", "Permission:ChangePermissions": "Engedélyek módosítása", + "Permission:ManageRoles": "Szerepkörök kezelése", "Permission:UserManagement": "Felhasználókezelés", "Permission:UserLookup": "Felhaszáló keresés", "DisplayName:Abp.Identity.Password.RequiredLength": "Szükséges hossz", @@ -127,4 +128,4 @@ "LockoutEndTime": "A zárolás befejezési ideje", "FailedAccessCount": "Sikertelen hozzáférések száma" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/is.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/is.json index d978250058c..e9509004d42 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/is.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/is.json @@ -85,6 +85,7 @@ "Permission:Edit": "Breyta", "Permission:Delete": "Eyða", "Permission:ChangePermissions": "Breyta heimildum", + "Permission:ManageRoles": "Hlutverka umsjón", "Permission:UserManagement": "Notanda umsjón", "Permission:UserLookup": "Leita að notanda", "DisplayName:Abp.Identity.Password.RequiredLength": "Nauðsynleg lengdh", @@ -127,4 +128,4 @@ "LockoutEndTime": "Lokatími lokunar", "FailedAccessCount": "Misheppnuð fjöldi aðgangs" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/it.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/it.json index dab7f027b79..ef6ed8c5fa5 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/it.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/it.json @@ -85,6 +85,7 @@ "Permission:Edit": "Modifica", "Permission:Delete": "Elimina", "Permission:ChangePermissions": "Modifica le autorizzazioni", + "Permission:ManageRoles": "Gestione ruoli", "Permission:UserManagement": "Gestione utenti", "Permission:UserLookup": "Ricerca utente", "DisplayName:Abp.Identity.Password.RequiredLength": "Lunghezza richiesta", @@ -127,4 +128,4 @@ "LockoutEndTime": "Ora di fine del blocco", "FailedAccessCount": "Conteggio accessi non riusciti" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/nl.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/nl.json index 57afe1c640e..291061f39d5 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/nl.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/nl.json @@ -85,6 +85,7 @@ "Permission:Edit": "Verander", "Permission:Delete": "Verwijder", "Permission:ChangePermissions": "Wijzig de rechten", + "Permission:ManageRoles": "Beheer rollen", "Permission:UserManagement": "Gebruikersbeheer", "Permission:UserLookup": "Gebruiker opzoeken", "DisplayName:Abp.Identity.Password.RequiredLength": "Vereiste lengte", @@ -127,4 +128,4 @@ "LockoutEndTime": "Eindtijd uitsluiting", "FailedAccessCount": "Aantal mislukte toegangen" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pl-PL.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pl-PL.json index 326e4217def..3be940bca75 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pl-PL.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pl-PL.json @@ -85,6 +85,7 @@ "Permission:Edit": "Edytuj", "Permission:Delete": "Usuń", "Permission:ChangePermissions": "Zmień uprawnienia", + "Permission:ManageRoles": "Zarządzaj rolami", "Permission:UserManagement": "Zarządzanie użytkownikami", "Permission:UserLookup": "Wyszukiwanie użytkownika", "DisplayName:Abp.Identity.Password.RequiredLength": "Wymagana długość", @@ -127,4 +128,4 @@ "LockoutEndTime": "Czas zakończenia blokady", "FailedAccessCount": "Liczba nieudanych dostępów" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pt-BR.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pt-BR.json index 26141814363..0cb440915d3 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pt-BR.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/pt-BR.json @@ -85,6 +85,7 @@ "Permission:Edit": "Editar", "Permission:Delete": "Excluir", "Permission:ChangePermissions": "Alterar Permissões", + "Permission:ManageRoles": "Gerenciar Perfis", "Permission:UserManagement": "Usuários", "Permission:UserLookup": "Pesquisa de usuário", "DisplayName:Abp.Identity.Password.RequiredLength": "Comprimento requerido", @@ -127,4 +128,4 @@ "LockoutEndTime": "Hora de término do bloqueio", "FailedAccessCount": "Contagem de acessos com falha" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ro-RO.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ro-RO.json index 525471262d4..995db6bac12 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ro-RO.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ro-RO.json @@ -85,6 +85,7 @@ "Permission:Edit": "Editează", "Permission:Delete": "Şterge", "Permission:ChangePermissions": "Schimbă permisiunile", + "Permission:ManageRoles": "Administrarea rolurilor", "Permission:UserManagement": "Administrarea utilizatorilor", "Permission:UserLookup": "Căutarea utilizatorilor", "DisplayName:Abp.Identity.Password.RequiredLength": "Lungimea necesară", @@ -127,4 +128,4 @@ "LockoutEndTime": "Ora de încheiere a blocării", "FailedAccessCount": "Număr de acces eșuat" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ru.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ru.json index 3e960ded9c9..79d4e83075b 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ru.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/ru.json @@ -85,6 +85,7 @@ "Permission:Edit": "Редактировать", "Permission:Delete": "Удалить", "Permission:ChangePermissions": "Изменить разрешения", + "Permission:ManageRoles": "Управление ролями", "Permission:UserManagement": "Управление пользователями", "Permission:UserLookup": "Поиск пользователя", "DisplayName:Abp.Identity.Password.RequiredLength": "Требуемая длина", @@ -127,4 +128,4 @@ "LockoutEndTime": "Время окончания блокировки", "FailedAccessCount": "Количество неудачных попыток доступа" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sk.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sk.json index 7f1041b756c..3ba7eb1184a 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sk.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sk.json @@ -85,6 +85,7 @@ "Permission:Edit": "Upraviť", "Permission:Delete": "Zmazať", "Permission:ChangePermissions": "Zmeniť oprávnenia", + "Permission:ManageRoles": "Správa rolí", "Permission:UserManagement": "Správa používateľov", "Permission:UserLookup": "Vyhľadať používateľov", "DisplayName:Abp.Identity.Password.RequiredLength": "Požadovaná dĺžka", @@ -127,4 +128,4 @@ "LockoutEndTime": "Čas ukončenia uzamknutia", "FailedAccessCount": "Počet neúspešných prístupov" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sl.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sl.json index 9032d14ca92..23e323c0e28 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sl.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/sl.json @@ -85,6 +85,7 @@ "Permission:Edit": "Urejanje", "Permission:Delete": "Brisanje", "Permission:ChangePermissions": "Spreminjanje dovoljenj", + "Permission:ManageRoles": "Upravljanje vlog", "Permission:UserManagement": "Upravljanje uporabnikov", "Permission:UserLookup": "Iskanje uporabnikov", "DisplayName:Abp.Identity.Password.RequiredLength": "Zahtevana dolžina", @@ -127,4 +128,4 @@ "LockoutEndTime": "Končni čas zaklepanja", "FailedAccessCount": "Število neuspešnih dostopov" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json index f4f61ce7986..c6386b499c2 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/tr.json @@ -85,6 +85,7 @@ "Permission:Edit": "Düzenleme", "Permission:Delete": "Silme", "Permission:ChangePermissions": "İzinleri değiştirme", + "Permission:ManageRoles": "Rolleri yönetme", "Permission:UserManagement": "Kullanıcı yönetimi", "Permission:UserLookup": "Kullanıcı sorgulama", "DisplayName:Abp.Identity.Password.RequiredLength": "Uzunluk gerekli", diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/vi.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/vi.json index 066ea8b5389..04d6c03cf20 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/vi.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/vi.json @@ -85,6 +85,7 @@ "Permission:Edit": "Sửa", "Permission:Delete": "Xóa", "Permission:ChangePermissions": "Thay đổi quyền", + "Permission:ManageRoles": "Quản lý vai trò", "Permission:UserManagement": "Quản lý người dùng", "Permission:UserLookup": "Tra cứu người dùng", "DisplayName:Abp.Identity.Password.RequiredLength": "Chiều dài yêu cầu", @@ -127,4 +128,4 @@ "LockoutEndTime": "Thời gian kết thúc khóa", "FailedAccessCount": "Số lượt truy cập không thành công" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hans.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hans.json index 5d2c2d769df..a6a008f920a 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hans.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hans.json @@ -85,6 +85,7 @@ "Permission:Edit": "编辑", "Permission:Delete": "删除", "Permission:ChangePermissions": "更改权限", + "Permission:ManageRoles": "管理角色", "Permission:UserManagement": "用户管理", "Permission:UserLookup": "用户查询", "DisplayName:Abp.Identity.Password.RequiredLength": "要求长度", @@ -127,4 +128,4 @@ "LockoutEndTime": "锁定结束时间", "FailedAccessCount": "访问失败次数" } -} \ No newline at end of file +} diff --git a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hant.json b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hant.json index 6a90b029ecd..db10b63ebd8 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hant.json +++ b/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/zh-Hant.json @@ -85,6 +85,7 @@ "Permission:Edit": "編輯", "Permission:Delete": "刪除", "Permission:ChangePermissions": "更改權限", + "Permission:ManageRoles": "管理角色", "Permission:UserManagement": "使用者管理", "Permission:UserLookup": "使用者查詢", "DisplayName:Abp.Identity.Password.RequiredLength": "長度需符合", 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 521c977dae6..9dc1958d636 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 @@ -66,25 +66,28 @@ else { + asp-for="UserInfo.ExtraProperties[propertyInfo.Name]" + label="@propertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)" + asp-format="@propertyInfo.GetInputFormatOrNull()" + value="@propertyInfo.GetInputValueOrNull(Model.UserInfo.GetProperty(propertyInfo.Name))" /> } } } - -
- @for (var i = 0; i < Model.Roles.Length; i++) - { - var role = Model.Roles[i]; - - - } -
-
+ @if (Model.Roles.Any()) + { + +
+ @for (var i = 0; i < Model.Roles.Length; i++) + { + var role = Model.Roles[i]; + + + } +
+
+ }
@@ -120,17 +123,17 @@ { const string DateTimeFormat = "MMMM dd, yyyy — HH:mm"; const string DefaultEmptyValue = "-"; - + static string ConvertUserFriendlyFormat(DateTime? dateTime) { return dateTime == null ? DefaultEmptyValue : dateTime.Value.ToUniversalTime().ToString(DateTimeFormat); } - + static string ConvertUserFriendlyFormat(DateTimeOffset? dateTime) { return dateTime == null ? DefaultEmptyValue : dateTime.Value.UtcDateTime.ToString(DateTimeFormat); } - + static string ConvertUserFriendlyFormat(string value) { return value.IsNullOrWhiteSpace() ? DefaultEmptyValue : value; 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 e73706262c6..69fe59db718 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 @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc; using Volo.Abp.Auditing; using Volo.Abp.Application.Dtos; +using Volo.Abp.Authorization.Permissions; using Volo.Abp.Domain.Entities; using Volo.Abp.ObjectExtending; using Volo.Abp.Validation; @@ -19,23 +20,29 @@ public class EditModalModel : IdentityPageModel [BindProperty] public AssignedRoleViewModel[] Roles { get; set; } - + public DetailViewModel Detail { get; set; } protected IIdentityUserAppService IdentityUserAppService { get; } + protected IPermissionChecker PermissionChecker { get; } + public bool IsEditCurrentUser { get; set; } - public EditModalModel(IIdentityUserAppService identityUserAppService) + public EditModalModel(IIdentityUserAppService identityUserAppService, IPermissionChecker permissionChecker) { IdentityUserAppService = identityUserAppService; + PermissionChecker = permissionChecker; } public virtual async Task OnGetAsync(Guid id) { var user = await IdentityUserAppService.GetAsync(id); UserInfo = ObjectMapper.Map(user); - Roles = ObjectMapper.Map, AssignedRoleViewModel[]>((await IdentityUserAppService.GetAssignableRolesAsync()).Items); + if (await PermissionChecker.IsGrantedAsync(IdentityPermissions.Users.ManageRoles)) + { + Roles = ObjectMapper.Map, AssignedRoleViewModel[]>((await IdentityUserAppService.GetAssignableRolesAsync()).Items); + } IsEditCurrentUser = CurrentUser.Id == id; var userRoleNames = (await IdentityUserAppService.GetRolesAsync(UserInfo.Id)).Items.Select(r => r.Name).ToList(); @@ -46,15 +53,15 @@ public virtual async Task OnGetAsync(Guid id) role.IsAssigned = true; } } - + Detail = ObjectMapper.Map(user); - + Detail.CreatedBy = await GetUserNameOrNullAsync(user.CreatorId); Detail.ModifiedBy = await GetUserNameOrNullAsync(user.LastModifierId); return Page(); } - + private async Task GetUserNameOrNullAsync(Guid? userId) { if (!userId.HasValue) @@ -126,14 +133,14 @@ public class DetailViewModel { public string CreatedBy { get; set; } public DateTime? CreationTime { get; set; } - + public string ModifiedBy { get; set; } public DateTime? LastModificationTime { get; set; } - + public DateTimeOffset? LastPasswordChangeTime { get; set; } public DateTimeOffset? LockoutEnd { get; set; } - + public int AccessFailedCount { get; set; } } }