diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-01-22 21:19:04 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-01-22 21:19:04 -0500 |
| commit | 4ce43ce019e24344f08ee6743c0efef7a03875a9 (patch) | |
| tree | c4b3cfb8636f5207cf8e40b0f39ee1f0504c84c7 | |
| parent | bd0a1b70d0fb293609683076f325cf655ef369ac (diff) | |
fixes #683 - Support disabling playback per user
| -rw-r--r-- | MediaBrowser.Api/Playback/BaseStreamingService.cs | 7 | ||||
| -rw-r--r-- | MediaBrowser.Model/Configuration/UserConfiguration.cs | 3 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/Session/SessionManager.cs | 10 |
3 files changed, 20 insertions, 0 deletions
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 6761c272d..394ca69d5 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -1007,6 +1007,13 @@ namespace MediaBrowser.Api.Playback throw 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.cs index 7cc61e7fd..ba4726956 100644 --- a/MediaBrowser.Model/Configuration/UserConfiguration.cs +++ b/MediaBrowser.Model/Configuration/UserConfiguration.cs @@ -68,6 +68,8 @@ namespace MediaBrowser.Model.Configuration public 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.Configuration BlockNotRated = false; EnableLiveTvManagement = true; + EnableMediaPlayback = true; } } } diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index d24de75cb..fd78d1aaa 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(); |
