#2618 - add backward compatibility for permissions optimizations
This commit is contained in:
		| @ -1,6 +1,7 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.ComponentModel.DataAnnotations.Schema; | ||||
| using System.Text.Json; | ||||
|  | ||||
| namespace Oqtane.Models | ||||
| { | ||||
| @ -69,7 +70,7 @@ namespace Oqtane.Models | ||||
|         /// TODO: todoc what would this contain? | ||||
|         /// </summary> | ||||
|         [NotMapped] | ||||
|         public List<Permission> Permissions { get; set; } | ||||
|         public List<Permission> PermissionList { get; set; } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Folder Depth | ||||
| @ -83,5 +84,19 @@ namespace Oqtane.Models | ||||
|         /// </summary> | ||||
|         [NotMapped] | ||||
|         public bool HasChildren { get; set; } | ||||
|  | ||||
|         [Obsolete("The Permissions property is deprecated. Use PermissionList instead", false)] | ||||
|         [NotMapped] | ||||
|         public string Permissions | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return JsonSerializer.Serialize(PermissionList); | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 PermissionList = JsonSerializer.Deserialize<List<Permission>>(Permissions); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -2,6 +2,7 @@ using Oqtane.Shared; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.ComponentModel.DataAnnotations.Schema; | ||||
| using System.Text.Json; | ||||
|  | ||||
| namespace Oqtane.Models | ||||
| { | ||||
| @ -42,7 +43,7 @@ namespace Oqtane.Models | ||||
|         #endregion | ||||
|          | ||||
|         [NotMapped] | ||||
|         public List<Permission> Permissions { get; set; } | ||||
|         public List<Permission> PermissionList { get; set; } | ||||
|  | ||||
|         [NotMapped] | ||||
|         public Dictionary<string, string> Settings { get; set; } | ||||
| @ -107,5 +108,19 @@ namespace Oqtane.Models | ||||
|         public bool UseAdminContainer { get; set; } | ||||
|  | ||||
|         #endregion | ||||
|  | ||||
|         [Obsolete("The Permissions property is deprecated. Use PermissionList instead", false)] | ||||
|         [NotMapped] | ||||
|         public string Permissions | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return JsonSerializer.Serialize(PermissionList); | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 PermissionList = JsonSerializer.Deserialize<List<Permission>>(Permissions); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.ComponentModel.DataAnnotations.Schema; | ||||
| using System.Text.Json; | ||||
| using Oqtane.Documentation; | ||||
|  | ||||
| namespace Oqtane.Models | ||||
| @ -100,8 +101,22 @@ namespace Oqtane.Models | ||||
|         [NotMapped] | ||||
|         public string AssemblyName { get; set; } | ||||
|         [NotMapped] | ||||
|         public List<Permission> Permissions { get; set; } | ||||
|         public List<Permission> PermissionList { get; set; } | ||||
|         [NotMapped] | ||||
|         public string Template { get; set; } | ||||
|  | ||||
|         [Obsolete("The Permissions property is deprecated. Use PermissionList instead", false)] | ||||
|         [NotMapped] | ||||
|         public string Permissions | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return JsonSerializer.Serialize(PermissionList); | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 PermissionList = JsonSerializer.Deserialize<List<Permission>>(Permissions); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.ComponentModel.DataAnnotations.Schema; | ||||
| using System.Text.Json; | ||||
|  | ||||
| namespace Oqtane.Models | ||||
| { | ||||
| @ -98,7 +99,7 @@ namespace Oqtane.Models | ||||
|         public List<Resource> Resources { get; set; } | ||||
|  | ||||
|         [NotMapped] | ||||
|         public List<Permission> Permissions { get; set; } | ||||
|         public List<Permission> PermissionList { get; set; } | ||||
|  | ||||
|         [NotMapped] | ||||
|         public Dictionary<string, string> Settings { get; set; } | ||||
| @ -122,6 +123,18 @@ namespace Oqtane.Models | ||||
|         [NotMapped] | ||||
|         public string LayoutType { get; set; } | ||||
|  | ||||
|         [Obsolete("The Permissions property is deprecated. Use PermissionList instead", false)] | ||||
|         [NotMapped] | ||||
|         public string Permissions { | ||||
|             get | ||||
|             { | ||||
|                 return JsonSerializer.Serialize(PermissionList); | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 PermissionList = JsonSerializer.Deserialize<List<Permission>>(Permissions); | ||||
|             } | ||||
|         } | ||||
|         #endregion | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,5 +1,7 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.ComponentModel.DataAnnotations.Schema; | ||||
| using System.Text.Json; | ||||
|  | ||||
| namespace Oqtane.Models | ||||
| { | ||||
| @ -18,11 +20,24 @@ namespace Oqtane.Models | ||||
|         public string Icon { get; set; } | ||||
|         public bool IsNavigation { get; set; } | ||||
|         public bool IsPersonalizable { get; set; } | ||||
|         public List<Permission> PagePermissions { get; set; } | ||||
|         public List<Permission> PermissionList { get; set; } | ||||
|         public List<PageTemplateModule> PageTemplateModules { get; set; } | ||||
|  | ||||
|         [Obsolete("This property is obsolete", false)] | ||||
|         public bool EditMode { get; set; } | ||||
|  | ||||
|         [Obsolete("The PagePermissions property is deprecated. Use PermissionList instead", false)] | ||||
|         public string PagePermissions | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return JsonSerializer.Serialize(PermissionList); | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 PermissionList = JsonSerializer.Deserialize<List<Permission>>(PagePermissions); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public class PageTemplateModule | ||||
| @ -30,7 +45,20 @@ namespace Oqtane.Models | ||||
|         public string ModuleDefinitionName { get; set; } | ||||
|         public string Title { get; set; } | ||||
|         public string Pane { get; set; } | ||||
|         public List<Permission> ModulePermissions { get; set; } | ||||
|         public List<Permission> PermissionList { get; set; } | ||||
|         public string Content { get; set; } | ||||
|  | ||||
|         [Obsolete("The ModulePermissions property is deprecated. Use PermissionList instead", false)] | ||||
|         public string ModulePermissions | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return JsonSerializer.Serialize(PermissionList); | ||||
|             } | ||||
|             set | ||||
|             { | ||||
|                 PermissionList = JsonSerializer.Deserialize<List<Permission>>(ModulePermissions); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -2,6 +2,7 @@ using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Security.Claims; | ||||
| using System.Text.Json; | ||||
| using Oqtane.Models; | ||||
| using Oqtane.Shared; | ||||
|  | ||||
| @ -24,6 +25,11 @@ namespace Oqtane.Security | ||||
|             return IsAuthorized(user, permissions.Where(item => item.PermissionName == permissionName).ToList()); | ||||
|         } | ||||
|  | ||||
|         public static bool IsAuthorized(User user, string permissionName, string permissions) | ||||
|         { | ||||
|             return IsAuthorized(user, JsonSerializer.Deserialize<List<Permission>>(permissions).Where(item => item.PermissionName == permissionName).ToList()); | ||||
|         } | ||||
|  | ||||
|         public static bool IsAuthorized(User user, List<Permission> permissions) | ||||
|         { | ||||
|             bool authorized = false; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shaun Walker
					Shaun Walker