The Free Software Media System - Server Backend & API
fixes #683 - Support disabling playback per user
Luke Pulverenti4ce43ce019e2
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.csindex 6761c272de..394ca69d5a 100644--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs@@ -1007,6 +1007,13 @@ namespace MediaBrowser.Api.Playbackthrow new InvalidOperationException("You asked for a debug error, you got one.");}+ var user = AuthorizationRequestFilterAttribute.GetCurrentUser(Request, UserManager);++ if (user != null && !user.Configuration.EnableMediaPlayback)+ {+ throw new ArgumentException(string.Format("{0} is not allowed to play media.", user.Name));+ }+var url = Request.PathInfo;if (!request.AudioCodec.HasValue)diff --git a/MediaBrowser.Model/Configuration/UserConfiguration.cs b/MediaBrowser.Model/Configuration/UserConfiguration.csindex 7cc61e7fdd..ba47269563 100644--- a/MediaBrowser.Model/Configuration/UserConfiguration.cs+++ b/MediaBrowser.Model/Configuration/UserConfiguration.cs@@ -68,6 +68,8 @@ namespace MediaBrowser.Model.Configurationpublic bool BlockUnratedBooks { get; set; }public bool EnableLiveTvManagement { get; set; }++ public bool EnableMediaPlayback { get; set; }/// <summary>/// Initializes a new instance of the <see cref="UserConfiguration" /> class.@@ -79,6 +81,7 @@ namespace MediaBrowser.Model.ConfigurationBlockNotRated = false;EnableLiveTvManagement = true;+ EnableMediaPlayback = true;}}}diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.csindex d24de75cb7..fd78d1aaa6 100644--- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs+++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs@@ -604,6 +604,16 @@ namespace MediaBrowser.Server.Implementations.Session{var session = GetSessionForRemoteControl(sessionId);+ if (session.UserId.HasValue)+ {+ var user = _userManager.GetUserById(session.UserId.Value);++ if (!user.Configuration.EnableMediaPlayback)+ {+ throw new ArgumentException(string.Format("{0} is not allowed to play media.", user.Name));+ }+ }+var items = command.ItemIds.Select(i => _libraryManager.GetItemById(new Guid(i))).ToList();