mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Merge pull request #11665 from Bond-009/getuserbyid
This commit is contained in:
commit
8c3f3c503b
@ -1530,7 +1530,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
{
|
{
|
||||||
var userViews = UserViewManager.GetUserViews(new UserViewQuery
|
var userViews = UserViewManager.GetUserViews(new UserViewQuery
|
||||||
{
|
{
|
||||||
UserId = user.Id,
|
User = user,
|
||||||
IncludeHidden = true,
|
IncludeHidden = true,
|
||||||
IncludeExternalContent = allowExternalContent
|
IncludeExternalContent = allowExternalContent
|
||||||
});
|
});
|
||||||
|
@ -16,7 +16,6 @@ using MediaBrowser.Controller.Entities;
|
|||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.LiveTv;
|
using MediaBrowser.Controller.LiveTv;
|
||||||
using MediaBrowser.Model.Channels;
|
using MediaBrowser.Model.Channels;
|
||||||
using MediaBrowser.Model.Entities;
|
|
||||||
using MediaBrowser.Model.Globalization;
|
using MediaBrowser.Model.Globalization;
|
||||||
using MediaBrowser.Model.Library;
|
using MediaBrowser.Model.Library;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
@ -27,17 +26,15 @@ namespace Emby.Server.Implementations.Library
|
|||||||
{
|
{
|
||||||
private readonly ILibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
private readonly ILocalizationManager _localizationManager;
|
private readonly ILocalizationManager _localizationManager;
|
||||||
private readonly IUserManager _userManager;
|
|
||||||
|
|
||||||
private readonly IChannelManager _channelManager;
|
private readonly IChannelManager _channelManager;
|
||||||
private readonly ILiveTvManager _liveTvManager;
|
private readonly ILiveTvManager _liveTvManager;
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
|
|
||||||
public UserViewManager(ILibraryManager libraryManager, ILocalizationManager localizationManager, IUserManager userManager, IChannelManager channelManager, ILiveTvManager liveTvManager, IServerConfigurationManager config)
|
public UserViewManager(ILibraryManager libraryManager, ILocalizationManager localizationManager, IChannelManager channelManager, ILiveTvManager liveTvManager, IServerConfigurationManager config)
|
||||||
{
|
{
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_localizationManager = localizationManager;
|
_localizationManager = localizationManager;
|
||||||
_userManager = userManager;
|
|
||||||
_channelManager = channelManager;
|
_channelManager = channelManager;
|
||||||
_liveTvManager = liveTvManager;
|
_liveTvManager = liveTvManager;
|
||||||
_config = config;
|
_config = config;
|
||||||
@ -45,11 +42,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
|
|
||||||
public Folder[] GetUserViews(UserViewQuery query)
|
public Folder[] GetUserViews(UserViewQuery query)
|
||||||
{
|
{
|
||||||
var user = _userManager.GetUserById(query.UserId);
|
var user = query.User;
|
||||||
if (user is null)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("User id specified in the query does not exist.", nameof(query));
|
|
||||||
}
|
|
||||||
|
|
||||||
var folders = _libraryManager.GetUserRootFolder()
|
var folders = _libraryManager.GetUserRootFolder()
|
||||||
.GetChildren(user, true)
|
.GetChildren(user, true)
|
||||||
@ -125,14 +118,14 @@ namespace Emby.Server.Implementations.Library
|
|||||||
{
|
{
|
||||||
var channelResult = _channelManager.GetChannelsInternalAsync(new ChannelQuery
|
var channelResult = _channelManager.GetChannelsInternalAsync(new ChannelQuery
|
||||||
{
|
{
|
||||||
UserId = query.UserId
|
UserId = user.Id
|
||||||
}).GetAwaiter().GetResult();
|
}).GetAwaiter().GetResult();
|
||||||
|
|
||||||
var channels = channelResult.Items;
|
var channels = channelResult.Items;
|
||||||
|
|
||||||
list.AddRange(channels);
|
list.AddRange(channels);
|
||||||
|
|
||||||
if (_liveTvManager.GetEnabledUsers().Select(i => i.Id).Contains(query.UserId))
|
if (_liveTvManager.GetEnabledUsers().Select(i => i.Id).Contains(user.Id))
|
||||||
{
|
{
|
||||||
list.Add(_liveTvManager.GetInternalLiveTvFolder(CancellationToken.None));
|
list.Add(_liveTvManager.GetInternalLiveTvFolder(CancellationToken.None));
|
||||||
}
|
}
|
||||||
@ -207,9 +200,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
|
|
||||||
public List<Tuple<BaseItem, List<BaseItem>>> GetLatestItems(LatestItemsQuery request, DtoOptions options)
|
public List<Tuple<BaseItem, List<BaseItem>>> GetLatestItems(LatestItemsQuery request, DtoOptions options)
|
||||||
{
|
{
|
||||||
var user = _userManager.GetUserById(request.UserId);
|
var libraryItems = GetItemsForLatestItems(request.User, request, options);
|
||||||
|
|
||||||
var libraryItems = GetItemsForLatestItems(user, request, options);
|
|
||||||
|
|
||||||
var list = new List<Tuple<BaseItem, List<BaseItem>>>();
|
var list = new List<Tuple<BaseItem, List<BaseItem>>>();
|
||||||
|
|
||||||
|
@ -19,14 +19,12 @@ namespace Emby.Server.Implementations.TV
|
|||||||
{
|
{
|
||||||
public class TVSeriesManager : ITVSeriesManager
|
public class TVSeriesManager : ITVSeriesManager
|
||||||
{
|
{
|
||||||
private readonly IUserManager _userManager;
|
|
||||||
private readonly IUserDataManager _userDataManager;
|
private readonly IUserDataManager _userDataManager;
|
||||||
private readonly ILibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
private readonly IServerConfigurationManager _configurationManager;
|
private readonly IServerConfigurationManager _configurationManager;
|
||||||
|
|
||||||
public TVSeriesManager(IUserManager userManager, IUserDataManager userDataManager, ILibraryManager libraryManager, IServerConfigurationManager configurationManager)
|
public TVSeriesManager(IUserDataManager userDataManager, ILibraryManager libraryManager, IServerConfigurationManager configurationManager)
|
||||||
{
|
{
|
||||||
_userManager = userManager;
|
|
||||||
_userDataManager = userDataManager;
|
_userDataManager = userDataManager;
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_configurationManager = configurationManager;
|
_configurationManager = configurationManager;
|
||||||
@ -34,12 +32,7 @@ namespace Emby.Server.Implementations.TV
|
|||||||
|
|
||||||
public QueryResult<BaseItem> GetNextUp(NextUpQuery query, DtoOptions options)
|
public QueryResult<BaseItem> GetNextUp(NextUpQuery query, DtoOptions options)
|
||||||
{
|
{
|
||||||
var user = _userManager.GetUserById(query.UserId);
|
var user = query.User;
|
||||||
|
|
||||||
if (user is null)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("User not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
string? presentationUniqueKey = null;
|
string? presentationUniqueKey = null;
|
||||||
if (!query.SeriesId.IsNullOrEmpty())
|
if (!query.SeriesId.IsNullOrEmpty())
|
||||||
@ -83,12 +76,7 @@ namespace Emby.Server.Implementations.TV
|
|||||||
|
|
||||||
public QueryResult<BaseItem> GetNextUp(NextUpQuery request, BaseItem[] parentsFolders, DtoOptions options)
|
public QueryResult<BaseItem> GetNextUp(NextUpQuery request, BaseItem[] parentsFolders, DtoOptions options)
|
||||||
{
|
{
|
||||||
var user = _userManager.GetUserById(request.UserId);
|
var user = request.User;
|
||||||
|
|
||||||
if (user is null)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("User not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
string? presentationUniqueKey = null;
|
string? presentationUniqueKey = null;
|
||||||
int? limit = null;
|
int? limit = null;
|
||||||
|
@ -109,7 +109,7 @@ public class ImageController : BaseJellyfinApiController
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!RequestHelpers.AssertCanUpdateUser(_userManager, HttpContext.User, requestUserId, true))
|
if (!RequestHelpers.AssertCanUpdateUser(HttpContext.User, user, true))
|
||||||
{
|
{
|
||||||
return StatusCode(StatusCodes.Status403Forbidden, "User is not allowed to update the image.");
|
return StatusCode(StatusCodes.Status403Forbidden, "User is not allowed to update the image.");
|
||||||
}
|
}
|
||||||
@ -203,13 +203,18 @@ public class ImageController : BaseJellyfinApiController
|
|||||||
[FromQuery] Guid? userId)
|
[FromQuery] Guid? userId)
|
||||||
{
|
{
|
||||||
var requestUserId = RequestHelpers.GetUserId(User, userId);
|
var requestUserId = RequestHelpers.GetUserId(User, userId);
|
||||||
if (!RequestHelpers.AssertCanUpdateUser(_userManager, HttpContext.User, requestUserId, true))
|
var user = _userManager.GetUserById(requestUserId);
|
||||||
|
if (user is null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RequestHelpers.AssertCanUpdateUser(HttpContext.User, user, true))
|
||||||
{
|
{
|
||||||
return StatusCode(StatusCodes.Status403Forbidden, "User is not allowed to delete the image.");
|
return StatusCode(StatusCodes.Status403Forbidden, "User is not allowed to delete the image.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var user = _userManager.GetUserById(requestUserId);
|
if (user.ProfileImage is null)
|
||||||
if (user?.ProfileImage is null)
|
|
||||||
{
|
{
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
@ -972,12 +972,17 @@ public class ItemsController : BaseJellyfinApiController
|
|||||||
[FromRoute, Required] Guid itemId)
|
[FromRoute, Required] Guid itemId)
|
||||||
{
|
{
|
||||||
var requestUserId = RequestHelpers.GetUserId(User, userId);
|
var requestUserId = RequestHelpers.GetUserId(User, userId);
|
||||||
if (!RequestHelpers.AssertCanUpdateUser(_userManager, User, requestUserId, true))
|
var user = _userManager.GetUserById(requestUserId);
|
||||||
|
if (user is null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RequestHelpers.AssertCanUpdateUser(User, user, true))
|
||||||
{
|
{
|
||||||
return StatusCode(StatusCodes.Status403Forbidden, "User is not allowed to view this item user data.");
|
return StatusCode(StatusCodes.Status403Forbidden, "User is not allowed to view this item user data.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var user = _userManager.GetUserById(requestUserId) ?? throw new ResourceNotFoundException();
|
|
||||||
var item = _libraryManager.GetItemById<BaseItem>(itemId, user);
|
var item = _libraryManager.GetItemById<BaseItem>(itemId, user);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
@ -1023,12 +1028,17 @@ public class ItemsController : BaseJellyfinApiController
|
|||||||
[FromBody, Required] UpdateUserItemDataDto userDataDto)
|
[FromBody, Required] UpdateUserItemDataDto userDataDto)
|
||||||
{
|
{
|
||||||
var requestUserId = RequestHelpers.GetUserId(User, userId);
|
var requestUserId = RequestHelpers.GetUserId(User, userId);
|
||||||
if (!RequestHelpers.AssertCanUpdateUser(_userManager, User, requestUserId, true))
|
var user = _userManager.GetUserById(requestUserId);
|
||||||
|
if (user is null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RequestHelpers.AssertCanUpdateUser(User, user, true))
|
||||||
{
|
{
|
||||||
return StatusCode(StatusCodes.Status403Forbidden, "User is not allowed to update this item user data.");
|
return StatusCode(StatusCodes.Status403Forbidden, "User is not allowed to update this item user data.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var user = _userManager.GetUserById(requestUserId) ?? throw new ResourceNotFoundException();
|
|
||||||
var item = _libraryManager.GetItemById<BaseItem>(itemId, user);
|
var item = _libraryManager.GetItemById<BaseItem>(itemId, user);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
|
@ -90,7 +90,12 @@ public class TvShowsController : BaseJellyfinApiController
|
|||||||
[FromQuery] bool enableResumable = true,
|
[FromQuery] bool enableResumable = true,
|
||||||
[FromQuery] bool enableRewatching = false)
|
[FromQuery] bool enableRewatching = false)
|
||||||
{
|
{
|
||||||
userId = RequestHelpers.GetUserId(User, userId);
|
var user = _userManager.GetUserById(RequestHelpers.GetUserId(User, userId));
|
||||||
|
if (user is null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
var options = new DtoOptions { Fields = fields }
|
var options = new DtoOptions { Fields = fields }
|
||||||
.AddClientFields(User)
|
.AddClientFields(User)
|
||||||
.AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
|
.AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
|
||||||
@ -102,7 +107,7 @@ public class TvShowsController : BaseJellyfinApiController
|
|||||||
ParentId = parentId,
|
ParentId = parentId,
|
||||||
SeriesId = seriesId,
|
SeriesId = seriesId,
|
||||||
StartIndex = startIndex,
|
StartIndex = startIndex,
|
||||||
UserId = userId.Value,
|
User = user,
|
||||||
EnableTotalRecordCount = enableTotalRecordCount,
|
EnableTotalRecordCount = enableTotalRecordCount,
|
||||||
DisableFirstEpisode = disableFirstEpisode,
|
DisableFirstEpisode = disableFirstEpisode,
|
||||||
NextUpDateCutoff = nextUpDateCutoff ?? DateTime.MinValue,
|
NextUpDateCutoff = nextUpDateCutoff ?? DateTime.MinValue,
|
||||||
@ -111,10 +116,6 @@ public class TvShowsController : BaseJellyfinApiController
|
|||||||
},
|
},
|
||||||
options);
|
options);
|
||||||
|
|
||||||
var user = userId.IsNullOrEmpty()
|
|
||||||
? null
|
|
||||||
: _userManager.GetUserById(userId.Value);
|
|
||||||
|
|
||||||
var returnItems = _dtoService.GetBaseItemDtos(result.Items, options, user);
|
var returnItems = _dtoService.GetBaseItemDtos(result.Items, options, user);
|
||||||
|
|
||||||
return new QueryResult<BaseItemDto>(
|
return new QueryResult<BaseItemDto>(
|
||||||
|
@ -274,16 +274,15 @@ public class UserController : BaseJellyfinApiController
|
|||||||
[FromBody, Required] UpdateUserPassword request)
|
[FromBody, Required] UpdateUserPassword request)
|
||||||
{
|
{
|
||||||
var requestUserId = userId ?? User.GetUserId();
|
var requestUserId = userId ?? User.GetUserId();
|
||||||
if (!RequestHelpers.AssertCanUpdateUser(_userManager, User, requestUserId, true))
|
|
||||||
{
|
|
||||||
return StatusCode(StatusCodes.Status403Forbidden, "User is not allowed to update the password.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var user = _userManager.GetUserById(requestUserId);
|
var user = _userManager.GetUserById(requestUserId);
|
||||||
|
|
||||||
if (user is null)
|
if (user is null)
|
||||||
{
|
{
|
||||||
return NotFound("User not found");
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RequestHelpers.AssertCanUpdateUser(User, user, true))
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status403Forbidden, "User is not allowed to update the password.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.ResetPassword)
|
if (request.ResetPassword)
|
||||||
@ -386,7 +385,7 @@ public class UserController : BaseJellyfinApiController
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!RequestHelpers.AssertCanUpdateUser(_userManager, User, requestUserId, true))
|
if (!RequestHelpers.AssertCanUpdateUser(User, user, true))
|
||||||
{
|
{
|
||||||
return StatusCode(StatusCodes.Status403Forbidden, "User update not allowed.");
|
return StatusCode(StatusCodes.Status403Forbidden, "User update not allowed.");
|
||||||
}
|
}
|
||||||
@ -396,7 +395,7 @@ public class UserController : BaseJellyfinApiController
|
|||||||
await _userManager.RenameUser(user, updateUser.Name).ConfigureAwait(false);
|
await _userManager.RenameUser(user, updateUser.Name).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
await _userManager.UpdateConfigurationAsync(user.Id, updateUser.Configuration).ConfigureAwait(false);
|
await _userManager.UpdateConfigurationAsync(requestUserId, updateUser.Configuration).ConfigureAwait(false);
|
||||||
|
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
@ -495,7 +494,13 @@ public class UserController : BaseJellyfinApiController
|
|||||||
[FromBody, Required] UserConfiguration userConfig)
|
[FromBody, Required] UserConfiguration userConfig)
|
||||||
{
|
{
|
||||||
var requestUserId = userId ?? User.GetUserId();
|
var requestUserId = userId ?? User.GetUserId();
|
||||||
if (!RequestHelpers.AssertCanUpdateUser(_userManager, User, requestUserId, true))
|
var user = _userManager.GetUserById(requestUserId);
|
||||||
|
if (user is null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RequestHelpers.AssertCanUpdateUser(User, user, true))
|
||||||
{
|
{
|
||||||
return StatusCode(StatusCodes.Status403Forbidden, "User configuration update not allowed");
|
return StatusCode(StatusCodes.Status403Forbidden, "User configuration update not allowed");
|
||||||
}
|
}
|
||||||
|
@ -560,7 +560,7 @@ public class UserLibraryController : BaseJellyfinApiController
|
|||||||
IsPlayed = isPlayed,
|
IsPlayed = isPlayed,
|
||||||
Limit = limit,
|
Limit = limit,
|
||||||
ParentId = parentId ?? Guid.Empty,
|
ParentId = parentId ?? Guid.Empty,
|
||||||
UserId = requestUserId,
|
User = user,
|
||||||
},
|
},
|
||||||
dtoOptions);
|
dtoOptions);
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ using Jellyfin.Api.Helpers;
|
|||||||
using Jellyfin.Api.ModelBinders;
|
using Jellyfin.Api.ModelBinders;
|
||||||
using Jellyfin.Api.Models.UserViewDtos;
|
using Jellyfin.Api.Models.UserViewDtos;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Controller.Dto;
|
using MediaBrowser.Controller.Dto;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
@ -69,8 +70,9 @@ public class UserViewsController : BaseJellyfinApiController
|
|||||||
[FromQuery] bool includeHidden = false)
|
[FromQuery] bool includeHidden = false)
|
||||||
{
|
{
|
||||||
userId = RequestHelpers.GetUserId(User, userId);
|
userId = RequestHelpers.GetUserId(User, userId);
|
||||||
|
var user = _userManager.GetUserById(userId.Value) ?? throw new ResourceNotFoundException();
|
||||||
|
|
||||||
var query = new UserViewQuery { UserId = userId.Value, IncludeHidden = includeHidden };
|
var query = new UserViewQuery { User = user, IncludeHidden = includeHidden };
|
||||||
|
|
||||||
if (includeExternalContent.HasValue)
|
if (includeExternalContent.HasValue)
|
||||||
{
|
{
|
||||||
@ -87,8 +89,6 @@ public class UserViewsController : BaseJellyfinApiController
|
|||||||
var dtoOptions = new DtoOptions().AddClientFields(User);
|
var dtoOptions = new DtoOptions().AddClientFields(User);
|
||||||
dtoOptions.Fields = [..dtoOptions.Fields, ItemFields.PrimaryImageAspectRatio, ItemFields.DisplayPreferencesId];
|
dtoOptions.Fields = [..dtoOptions.Fields, ItemFields.PrimaryImageAspectRatio, ItemFields.DisplayPreferencesId];
|
||||||
|
|
||||||
var user = _userManager.GetUserById(userId.Value);
|
|
||||||
|
|
||||||
var dtos = Array.ConvertAll(folders, i => _dtoService.GetBaseItemDto(i, dtoOptions, user));
|
var dtos = Array.ConvertAll(folders, i => _dtoService.GetBaseItemDto(i, dtoOptions, user));
|
||||||
|
|
||||||
return new QueryResult<BaseItemDto>(dtos);
|
return new QueryResult<BaseItemDto>(dtos);
|
||||||
|
@ -86,18 +86,17 @@ public static class RequestHelpers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if the user can update an entry.
|
/// Checks if the user can update an entry.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userManager">An instance of the <see cref="IUserManager"/> interface.</param>
|
|
||||||
/// <param name="claimsPrincipal">The <see cref="ClaimsPrincipal"/> for the current request.</param>
|
/// <param name="claimsPrincipal">The <see cref="ClaimsPrincipal"/> for the current request.</param>
|
||||||
/// <param name="userId">The user id.</param>
|
/// <param name="user">The user id.</param>
|
||||||
/// <param name="restrictUserPreferences">Whether to restrict the user preferences.</param>
|
/// <param name="restrictUserPreferences">Whether to restrict the user preferences.</param>
|
||||||
/// <returns>A <see cref="bool"/> whether the user can update the entry.</returns>
|
/// <returns>A <see cref="bool"/> whether the user can update the entry.</returns>
|
||||||
internal static bool AssertCanUpdateUser(IUserManager userManager, ClaimsPrincipal claimsPrincipal, Guid userId, bool restrictUserPreferences)
|
internal static bool AssertCanUpdateUser(ClaimsPrincipal claimsPrincipal, User user, bool restrictUserPreferences)
|
||||||
{
|
{
|
||||||
var authenticatedUserId = claimsPrincipal.GetUserId();
|
var authenticatedUserId = claimsPrincipal.GetUserId();
|
||||||
var isAdministrator = claimsPrincipal.IsInRole(UserRoles.Administrator);
|
var isAdministrator = claimsPrincipal.IsInRole(UserRoles.Administrator);
|
||||||
|
|
||||||
// If they're going to update the record of another user, they must be an administrator
|
// If they're going to update the record of another user, they must be an administrator
|
||||||
if (!userId.Equals(authenticatedUserId) && !isAdministrator)
|
if (!user.Id.Equals(authenticatedUserId) && !isAdministrator)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -108,12 +107,6 @@ public static class RequestHelpers
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var user = userManager.GetUserById(userId);
|
|
||||||
if (user is null)
|
|
||||||
{
|
|
||||||
throw new ResourceNotFoundException();
|
|
||||||
}
|
|
||||||
|
|
||||||
return user.EnableUserPreferenceAccess;
|
return user.EnableUserPreferenceAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1844,7 +1844,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
data.LastPlayedDate = datePlayed ?? data.LastPlayedDate ?? DateTime.UtcNow;
|
data.LastPlayedDate = datePlayed ?? data.LastPlayedDate ?? DateTime.UtcNow;
|
||||||
data.Played = true;
|
data.Played = true;
|
||||||
|
|
||||||
UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None);
|
UserDataManager.SaveUserData(user, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1866,7 +1866,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
data.LastPlayedDate = null;
|
data.LastPlayedDate = null;
|
||||||
data.Played = false;
|
data.Played = false;
|
||||||
|
|
||||||
UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None);
|
UserDataManager.SaveUserData(user, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -76,7 +76,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
|
|
||||||
var result = UserViewManager.GetUserViews(new UserViewQuery
|
var result = UserViewManager.GetUserViews(new UserViewQuery
|
||||||
{
|
{
|
||||||
UserId = query.User.Id,
|
User = query.User,
|
||||||
PresetViews = query.PresetViews
|
PresetViews = query.PresetViews
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
{
|
{
|
||||||
Limit = query.Limit,
|
Limit = query.Limit,
|
||||||
StartIndex = query.StartIndex,
|
StartIndex = query.StartIndex,
|
||||||
UserId = query.User.Id
|
User = query.User
|
||||||
},
|
},
|
||||||
parentFolders,
|
parentFolders,
|
||||||
query.DtoOptions);
|
query.DtoOptions);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma warning disable CS1591
|
#pragma warning disable CS1591
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using Jellyfin.Data.Entities;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Library
|
namespace MediaBrowser.Model.Library
|
||||||
@ -14,10 +15,10 @@ namespace MediaBrowser.Model.Library
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the user identifier.
|
/// Gets or sets the user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The user identifier.</value>
|
/// <value>The user.</value>
|
||||||
public Guid UserId { get; set; }
|
public required User User { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether [include external content].
|
/// Gets or sets a value indicating whether [include external content].
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#pragma warning disable CS1591
|
#pragma warning disable CS1591
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using Jellyfin.Data.Entities;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ namespace MediaBrowser.Model.Querying
|
|||||||
/// Gets or sets the user to localize search results for.
|
/// Gets or sets the user to localize search results for.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The user id.</value>
|
/// <value>The user id.</value>
|
||||||
public Guid UserId { get; set; }
|
public User User { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the parent id.
|
/// Gets or sets the parent id.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#nullable disable
|
|
||||||
#pragma warning disable CS1591
|
#pragma warning disable CS1591
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using Jellyfin.Data.Entities;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Querying
|
namespace MediaBrowser.Model.Querying
|
||||||
@ -19,10 +19,10 @@ namespace MediaBrowser.Model.Querying
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the user id.
|
/// Gets or sets the user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The user id.</value>
|
/// <value>The user.</value>
|
||||||
public Guid UserId { get; set; }
|
public required User User { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the parent identifier.
|
/// Gets or sets the parent identifier.
|
||||||
@ -48,24 +48,6 @@ namespace MediaBrowser.Model.Querying
|
|||||||
/// <value>The limit.</value>
|
/// <value>The limit.</value>
|
||||||
public int? Limit { get; set; }
|
public int? Limit { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// gets or sets the fields to return within the items, in addition to basic information.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The fields.</value>
|
|
||||||
public ItemFields[] Fields { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether [enable images].
|
|
||||||
/// </summary>
|
|
||||||
/// <value><c>null</c> if [enable images] contains no value, <c>true</c> if [enable images]; otherwise, <c>false</c>.</value>
|
|
||||||
public bool? EnableImages { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the image type limit.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The image type limit.</value>
|
|
||||||
public int? ImageTypeLimit { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the enable image types.
|
/// Gets or sets the enable image types.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user