From bc2e3a7333609c10f128fa0c206054e9fd528dd4 Mon Sep 17 00:00:00 2001 From: Leigh Date: Fri, 30 Apr 2021 09:36:50 +0200 Subject: [PATCH 1/2] Permissions for edit are applied from the page permissions. --- Oqtane.Client/Themes/Controls/Theme/ControlPanel.razor | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Oqtane.Client/Themes/Controls/Theme/ControlPanel.razor b/Oqtane.Client/Themes/Controls/Theme/ControlPanel.razor index 5c93bc9c4..b26567411 100644 --- a/Oqtane.Client/Themes/Controls/Theme/ControlPanel.razor +++ b/Oqtane.Client/Themes/Controls/Theme/ControlPanel.razor @@ -369,7 +369,10 @@ module.PageId = PageState.Page.PageId; module.ModuleDefinitionName = ModuleDefinitionName; module.AllPages = false; - module.Permissions = PageState.Page.Permissions; + List permissions = UserSecurity.GetPermissionStrings(PageState.Page.Permissions); + permissions.Remove(permissions.Find(p => p.PermissionName == PermissionNames.View)); + List editpermissions = permissions.Find(p => p.PermissionName == PermissionNames.Edit).Permissions.Split(";").ToList(); + permissions.Add(new PermissionString { PermissionName = PermissionNames.View, Permissions = string.Join(";", editpermissions.ToArray()) }); module = await ModuleService.AddModuleAsync(module); ModuleId = module.ModuleId.ToString(); } From 2be48e910e56e687bd9e7ce8097a1180cecaa899 Mon Sep 17 00:00:00 2001 From: Leigh Date: Fri, 30 Apr 2021 14:15:56 +0200 Subject: [PATCH 2/2] Set module view permissions to page edit permissions --- Oqtane.Client/Themes/Controls/Theme/ControlPanel.razor | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Oqtane.Client/Themes/Controls/Theme/ControlPanel.razor b/Oqtane.Client/Themes/Controls/Theme/ControlPanel.razor index b26567411..e53b97a1c 100644 --- a/Oqtane.Client/Themes/Controls/Theme/ControlPanel.razor +++ b/Oqtane.Client/Themes/Controls/Theme/ControlPanel.razor @@ -369,10 +369,12 @@ module.PageId = PageState.Page.PageId; module.ModuleDefinitionName = ModuleDefinitionName; module.AllPages = false; + + // set module view permissions to page edit permissions List permissions = UserSecurity.GetPermissionStrings(PageState.Page.Permissions); - permissions.Remove(permissions.Find(p => p.PermissionName == PermissionNames.View)); - List editpermissions = permissions.Find(p => p.PermissionName == PermissionNames.Edit).Permissions.Split(";").ToList(); - permissions.Add(new PermissionString { PermissionName = PermissionNames.View, Permissions = string.Join(";", editpermissions.ToArray()) }); + permissions.Find(p => p.PermissionName == PermissionNames.View).Permissions = permissions.Find(p => p.PermissionName == PermissionNames.Edit).Permissions; + module.Permissions = UserSecurity.SetPermissionStrings(permissions); + module = await ModuleService.AddModuleAsync(module); ModuleId = module.ModuleId.ToString(); }