From 454933733574dae8fa9b255d62a89cf953f1fe44 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 15 May 2024 17:51:40 +0200 Subject: Change arguments AssertCanUpdateUser to take a user --- Jellyfin.Api/Helpers/RequestHelpers.cs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'Jellyfin.Api/Helpers') diff --git a/Jellyfin.Api/Helpers/RequestHelpers.cs b/Jellyfin.Api/Helpers/RequestHelpers.cs index a3d7f471e..1d9c189a0 100644 --- a/Jellyfin.Api/Helpers/RequestHelpers.cs +++ b/Jellyfin.Api/Helpers/RequestHelpers.cs @@ -86,18 +86,17 @@ public static class RequestHelpers /// /// Checks if the user can update an entry. /// - /// An instance of the interface. /// The for the current request. - /// The user id. + /// The user id. /// Whether to restrict the user preferences. /// A whether the user can update the entry. - 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 isAdministrator = claimsPrincipal.IsInRole(UserRoles.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; } @@ -108,12 +107,6 @@ public static class RequestHelpers return true; } - var user = userManager.GetUserById(userId); - if (user is null) - { - throw new ResourceNotFoundException(); - } - return user.EnableUserPreferenceAccess; } -- cgit v1.2.3