diff options
| author | Bond_009 <bond.009@outlook.com> | 2024-05-15 17:51:40 +0200 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2024-08-05 17:17:57 +0200 |
| commit | 454933733574dae8fa9b255d62a89cf953f1fe44 (patch) | |
| tree | b6fdf84dd829fcb63433816f52a92c4b798701d3 /Jellyfin.Api/Helpers/RequestHelpers.cs | |
| parent | c831af2fe23b6400ea6ee9a57b938a594b654ad5 (diff) | |
Change arguments AssertCanUpdateUser to take a user
Diffstat (limited to 'Jellyfin.Api/Helpers/RequestHelpers.cs')
| -rw-r--r-- | Jellyfin.Api/Helpers/RequestHelpers.cs | 13 |
1 files changed, 3 insertions, 10 deletions
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 /// <summary> /// Checks if the user can update an entry. /// </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="userId">The user id.</param> + /// <param name="user">The user id.</param> /// <param name="restrictUserPreferences">Whether to restrict the user preferences.</param> /// <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 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; } |
