浏览代码

Validate cast receiver id on get/set

Cody Robibero 1 年之前
父节点
当前提交
bc88c96cbe
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      Jellyfin.Server.Implementations/Users/UserManager.cs

+ 6 - 2
Jellyfin.Server.Implementations/Users/UserManager.cs

@@ -328,7 +328,8 @@ namespace Jellyfin.Server.Implementations.Users
                     LatestItemsExcludes = user.GetPreferenceValues<Guid>(PreferenceKind.LatestItemExcludes),
                     CastReceiverId = string.IsNullOrEmpty(user.CastReceiverId)
                         ? _serverConfigurationManager.Configuration.CastReceiverApplications.FirstOrDefault()?.Id
-                        : user.CastReceiverId
+                        : _serverConfigurationManager.Configuration.CastReceiverApplications.FirstOrDefault(c => string.Equals(c.Id, user.CastReceiverId, StringComparison.Ordinal))?.Id
+                          ?? _serverConfigurationManager.Configuration.CastReceiverApplications.FirstOrDefault()?.Id
                 },
                 Policy = new UserPolicy
                 {
@@ -616,7 +617,10 @@ namespace Jellyfin.Server.Implementations.Users
                 user.EnableNextEpisodeAutoPlay = config.EnableNextEpisodeAutoPlay;
                 user.RememberSubtitleSelections = config.RememberSubtitleSelections;
                 user.SubtitleLanguagePreference = config.SubtitleLanguagePreference;
-                if (!string.IsNullOrEmpty(config.CastReceiverId))
+
+                // Only set cast receiver id if it is passed in and it exists in the server config.
+                if (!string.IsNullOrEmpty(config.CastReceiverId)
+                    && _serverConfigurationManager.Configuration.CastReceiverApplications.Any(c => string.Equals(c.Id, config.CastReceiverId, StringComparison.Ordinal)))
                 {
                     user.CastReceiverId = config.CastReceiverId;
                 }