mirror of https://github.com/jellyfin/jellyfin.git
Use elevated access control for media folders endpoint
This commit is contained in:
parent
9f352ccb5b
commit
c6dbcb661b
|
@ -485,18 +485,12 @@ namespace Jellyfin.Api.Controllers
|
||||||
/// <response code="200">Media folders returned.</response>
|
/// <response code="200">Media folders returned.</response>
|
||||||
/// <returns>List of user media folders.</returns>
|
/// <returns>List of user media folders.</returns>
|
||||||
[HttpGet("Library/MediaFolders")]
|
[HttpGet("Library/MediaFolders")]
|
||||||
[Authorize(Policy = Policies.DefaultAuthorization)]
|
[Authorize(Policy = Policies.RequiresElevation)]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public ActionResult<QueryResult<BaseItemDto>> GetMediaFolders([FromQuery] bool? isHidden)
|
public ActionResult<QueryResult<BaseItemDto>> GetMediaFolders([FromQuery] bool? isHidden)
|
||||||
{
|
{
|
||||||
var items = _libraryManager.GetUserRootFolder().Children.Concat(_libraryManager.RootFolder.VirtualChildren).OrderBy(i => i.SortName).ToList();
|
var items = _libraryManager.GetUserRootFolder().Children.Concat(_libraryManager.RootFolder.VirtualChildren).OrderBy(i => i.SortName).ToList();
|
||||||
|
|
||||||
if (!User.GetIsApiKey() && !User.IsInRole(UserRoles.Administrator))
|
|
||||||
{
|
|
||||||
var user = _userManager.GetUserById(User.GetUserId());
|
|
||||||
items = items.Where(i => i.IsVisible(user)).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isHidden.HasValue)
|
if (isHidden.HasValue)
|
||||||
{
|
{
|
||||||
var val = isHidden.Value;
|
var val = isHidden.Value;
|
||||||
|
|
Loading…
Reference in New Issue