From 0ab909de33d15ae6b208703392c16955725a01f3 Mon Sep 17 00:00:00 2001 From: Cody Robibero Date: Tue, 30 Apr 2024 17:44:09 -0600 Subject: [PATCH] Always attempt to get User if a user id is provided --- Jellyfin.Api/Controllers/ItemsController.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jellyfin.Api/Controllers/ItemsController.cs b/Jellyfin.Api/Controllers/ItemsController.cs index 70f805336b..cd4a0a23b1 100644 --- a/Jellyfin.Api/Controllers/ItemsController.cs +++ b/Jellyfin.Api/Controllers/ItemsController.cs @@ -246,9 +246,9 @@ public class ItemsController : BaseJellyfinApiController var isApiKey = User.GetIsApiKey(); // if api key is used (auth.IsApiKey == true), then `user` will be null throughout this method userId = RequestHelpers.GetUserId(User, userId); - var user = !isApiKey && !userId.IsNullOrEmpty() - ? _userManager.GetUserById(userId.Value) ?? throw new ResourceNotFoundException() - : null; + var user = userId.IsNullOrEmpty() + ? null + : _userManager.GetUserById(userId.Value) ?? throw new ResourceNotFoundException(); // beyond this point, we're either using an api key or we have a valid user if (!isApiKey && user is null)