public static bool HasPermission(string username, Common.AdminPermission[] AllowedPermissions) { try { var role = SecurityQuery.GetRoleByUsername(username); //Return true if the user is a Super Admin if (role.Permissions.Any(r => r.Name.ToLower() == Common.AdminPermission.SuperAdminPermission.ToString().ToLower())) return true; foreach (var permission in AllowedPermissions) { if (role.Permissions.Any(r => r.Name.ToLower() == permission.ToString().ToLower())) return true; } return false; } catch (Exception ex) { LogManager.LogException(ex); return false; } }
public PermissionCategoryAttribute(Common.PermissionCategory category) { Category = category.ToString(); }