From 46b37afef8728e9b8bce9327db2495157a7fecf2 Mon Sep 17 00:00:00 2001 From: hyzx86 Date: Tue, 3 Jan 2023 02:32:37 +0800 Subject: [PATCH 1/3] fix role update --- .../OrchardCore.Roles/Controllers/AdminController.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Roles/Controllers/AdminController.cs index 3d28a912373..bc5d9574a1b 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Controllers/AdminController.cs @@ -216,10 +216,8 @@ public async Task EditPost(string id, string roleDescription) rolesDocument.PermissionGroups.TryAdd(role.RoleName, new List()); - var permissionNames = _permissionProviders.SelectMany(x => x.GetDefaultStereotypes()) - .SelectMany(y => y.Permissions ?? Enumerable.Empty()) - .Select(x => x.Name) - .ToList(); + var installedPermissions = await GetInstalledPermissionsAsync(); + var allPermissions = installedPermissions.SelectMany(x => x.Value).Select(x=>x.Name); // Save var rolePermissions = new List(); @@ -232,7 +230,7 @@ public async Task EditPost(string id, string roleDescription) permissionName = key.Substring("Checkbox.".Length); } - if (!permissionNames.Contains(permissionName, StringComparer.OrdinalIgnoreCase)) + if (!allPermissions.Contains(permissionName, StringComparer.OrdinalIgnoreCase)) { // The request contains an invalid permission, let's ignore it continue; From 5e863ba8558ea74740c22c53801af3de1f8753bf Mon Sep 17 00:00:00 2001 From: Tony Han Date: Wed, 4 Jan 2023 03:48:08 +0800 Subject: [PATCH 2/3] Update src/OrchardCore.Modules/OrchardCore.Roles/Controllers/AdminController.cs Co-authored-by: Mike Alhayek --- .../OrchardCore.Roles/Controllers/AdminController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Roles/Controllers/AdminController.cs index bc5d9574a1b..cc1abf7808e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Controllers/AdminController.cs @@ -217,7 +217,7 @@ public async Task EditPost(string id, string roleDescription) rolesDocument.PermissionGroups.TryAdd(role.RoleName, new List()); var installedPermissions = await GetInstalledPermissionsAsync(); - var allPermissions = installedPermissions.SelectMany(x => x.Value).Select(x=>x.Name); + var allPermissions = installedPermissions.SelectMany(x => x.Value).Select(x => x.Name); // Save var rolePermissions = new List(); From 8b7374f86130cbc35fd97f005a7d1a0085508e54 Mon Sep 17 00:00:00 2001 From: hyzx86 Date: Wed, 4 Jan 2023 03:52:46 +0800 Subject: [PATCH 3/3] Update variable naming --- .../OrchardCore.Roles/Controllers/AdminController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Roles/Controllers/AdminController.cs index cc1abf7808e..6b28253bc78 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Controllers/AdminController.cs @@ -217,7 +217,7 @@ public async Task EditPost(string id, string roleDescription) rolesDocument.PermissionGroups.TryAdd(role.RoleName, new List()); var installedPermissions = await GetInstalledPermissionsAsync(); - var allPermissions = installedPermissions.SelectMany(x => x.Value).Select(x => x.Name); + var permissionNames = installedPermissions.SelectMany(x => x.Value).Select(x=>x.Name); // Save var rolePermissions = new List(); @@ -230,7 +230,7 @@ public async Task EditPost(string id, string roleDescription) permissionName = key.Substring("Checkbox.".Length); } - if (!allPermissions.Contains(permissionName, StringComparer.OrdinalIgnoreCase)) + if (!permissionNames.Contains(permissionName, StringComparer.OrdinalIgnoreCase)) { // The request contains an invalid permission, let's ignore it continue;