Skip to content

Commit

Permalink
Merge branch 'main' into ma/fix-unread-notification-counter
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek authored Jan 9, 2025
2 parents b3d0112 + d93ff43 commit 947a8b3
Show file tree
Hide file tree
Showing 23 changed files with 78 additions and 61 deletions.
4 changes: 3 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Owin" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Authorization" Version="9.0.0" />

<!-- dotnet/extensions repository -->
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="9.0.0" />
Expand All @@ -164,7 +165,8 @@
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.11" />
<PackageVersion Include="Microsoft.AspNetCore.Owin" Version="8.0.11" />
<PackageVersion Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="8.0.11" />

<PackageVersion Include="Microsoft.AspNetCore.Authorization" Version="8.0.11" />

<!-- dotnet/extensions repository -->
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="8.10.0" />

Expand Down
7 changes: 7 additions & 0 deletions OrchardCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.UrlRewriting.Ab
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrchardCore.UrlRewriting.Core", "src\OrchardCore\OrchardCore.UrlRewriting.Core\OrchardCore.UrlRewriting.Core.csproj", "{7B18DD99-A7BB-4297-8679-D87289758756}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrchardCore.Roles.Abstractions", "src\OrchardCore\OrchardCore.Roles.Abstractions\OrchardCore.Roles.Abstractions.csproj", "{F5E7DCC3-12C2-4363-9702-639561A8101C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1408,6 +1410,10 @@ Global
{7B18DD99-A7BB-4297-8679-D87289758756}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B18DD99-A7BB-4297-8679-D87289758756}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B18DD99-A7BB-4297-8679-D87289758756}.Release|Any CPU.Build.0 = Release|Any CPU
{F5E7DCC3-12C2-4363-9702-639561A8101C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F5E7DCC3-12C2-4363-9702-639561A8101C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F5E7DCC3-12C2-4363-9702-639561A8101C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F5E7DCC3-12C2-4363-9702-639561A8101C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1651,6 +1657,7 @@ Global
{D0F8B342-BDA8-44CB-AA43-7A65C79636A2} = {A066395F-6F73-45DC-B5A6-B4E306110DCE}
{675C8A76-C64F-47EC-B4F5-06D4F2D9662A} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{7B18DD99-A7BB-4297-8679-D87289758756} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
{F5E7DCC3-12C2-4363-9702-639561A8101C} = {F23AC6C2-DE44-4699-999D-3C478EF3D691}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {46A1D25A-78D1-4476-9CBF-25B75E296341}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Navigation.Core\OrchardCore.Navigation.Core.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Admin.Abstractions\OrchardCore.Admin.Abstractions.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.DisplayManagement\OrchardCore.DisplayManagement.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Roles.Abstractions\OrchardCore.Roles.Abstractions.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Users.Core\OrchardCore.Users.Core.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ResourceManagement\OrchardCore.ResourceManagement.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public ValueTask<FluidValue> ProcessAsync(FluidValue input, FilterArguments argu
{
var urlHelper = _urlHelperFactory.GetUrlHelper(context.ViewContext);

return ValueTask.FromResult<FluidValue>(new StringValue((urlHelper).Content(input.ToStringValue())));
var trimmedInputString = input.ToStringValue().Trim();
var absoluteUrl = urlHelper.Content(trimmedInputString);

return ValueTask.FromResult<FluidValue>(new StringValue(absoluteUrl));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Security.Services;
using OrchardCore.Users.Indexes;
using OrchardCore.Users.Models;
using YesSql.Filters.Query;
using YesSql.Services;

namespace OrchardCore.Users.Services;

public sealed class RolesAdminListFilterProvider : IUsersAdminListFilterProvider
{
public void Build(QueryEngineBuilder<User> builder)
{
builder.WithNamedTerm("role-restriction", builder => builder
.OneCondition(async (contentType, query, ctx) =>
{
var context = (UserQueryContext)ctx;

var httpContextAccessor = context.ServiceProvider.GetRequiredService<IHttpContextAccessor>();
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>();
var roleService = context.ServiceProvider.GetRequiredService<IRoleService>();

var user = httpContextAccessor.HttpContext?.User;

if (user != null && !await authorizationService.AuthorizeAsync(user, CommonPermissions.ListUsers))
{
// At this point the user cannot see all users, so lets see what role does he have access too and filter by them.
var accessibleRoles = (await roleService.GetAssignableRolesAsync()).Select(x => x.RoleName);

query.With<UserByRoleNameIndex>(index => index.RoleName.IsIn(accessibleRoles));
}

return query;
}).AlwaysRun()
);
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<RootNamespace>OrchardCore.Roles</RootNamespace>
<!-- NuGet properties-->
<Title>OrchardCore Roles Abstractions</Title>
<Description>
$(OCCMSDescription)

Abstractions for OrchardCoreCMS Roles
</Description>
<PackageTags>$(PackageTags) OrchardCoreCMS Roles Abstractions</PackageTags>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authorization" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\OrchardCore.Infrastructure.Abstractions\OrchardCore.Infrastructure.Abstractions.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,4 @@ public static async Task<IEnumerable<IRole>> GetAccessibleRolesAsync(this IRoleS

return accessibleRoles;
}

[Obsolete("This method is obsolete and will be removed in future releases.")]
public static async Task<IEnumerable<string>> GetAccessibleRoleNamesAsync(this IRoleService roleService, IAuthorizationService authorizationService, ClaimsPrincipal user, Permission permission)
{
var roles = await roleService.GetAccessibleRolesAsync(authorizationService, user, permission);

return roles.Select(x => x.RoleName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

<ItemGroup>
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Infrastructure.Abstractions\OrchardCore.Infrastructure.Abstractions.csproj" />
<ProjectReference Include="..\OrchardCore.Roles.Abstractions\OrchardCore.Roles.Abstractions.csproj" />
</ItemGroup>

</Project>

0 comments on commit 947a8b3

Please sign in to comment.