From 5c615fa02448813499ed87f2a1c2b937c7a7dcd5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 14 Sep 2014 11:10:51 -0400 Subject: add connect linking --- .../Channels/ChannelManager.cs | 14 +- .../Connect/ConnectData.cs | 26 ++- .../Connect/ConnectManager.cs | 209 +++++++++++++++++++-- .../Connect/Responses.cs | 28 +++ .../Connect/ServerRegistrationResponse.cs | 18 -- .../HttpServer/Security/AuthService.cs | 2 +- .../Library/SearchEngine.cs | 2 +- .../Library/UserManager.cs | 16 +- .../Library/UserViewManager.cs | 2 +- .../LiveTv/LiveTvManager.cs | 16 +- .../Localization/JavaScript/javascript.json | 7 +- .../Localization/Server/server.json | 6 +- .../MediaBrowser.Server.Implementations.csproj | 2 +- .../Notifications/NotificationManager.cs | 2 +- .../Playlists/PlaylistManager.cs | 6 +- .../Session/SessionManager.cs | 4 +- .../TV/TVSeriesManager.cs | 4 +- 17 files changed, 298 insertions(+), 66 deletions(-) create mode 100644 MediaBrowser.Server.Implementations/Connect/Responses.cs delete mode 100644 MediaBrowser.Server.Implementations/Connect/ServerRegistrationResponse.cs (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs index c7ca6bb30..dfd24a248 100644 --- a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs +++ b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs @@ -110,7 +110,7 @@ namespace MediaBrowser.Server.Implementations.Channels { var user = string.IsNullOrWhiteSpace(query.UserId) ? null - : _userManager.GetUserById(new Guid(query.UserId)); + : _userManager.GetUserById(query.UserId); var channels = GetAllChannels() .Select(GetChannelEntity) @@ -163,7 +163,7 @@ namespace MediaBrowser.Server.Implementations.Channels { var user = string.IsNullOrWhiteSpace(query.UserId) ? null - : _userManager.GetUserById(new Guid(query.UserId)); + : _userManager.GetUserById(query.UserId); var internalResult = await GetChannelsInternal(query, cancellationToken).ConfigureAwait(false); @@ -565,7 +565,7 @@ namespace MediaBrowser.Server.Implementations.Channels { var user = string.IsNullOrWhiteSpace(query.UserId) ? null - : _userManager.GetUserById(new Guid(query.UserId)); + : _userManager.GetUserById(query.UserId); if (!string.IsNullOrWhiteSpace(query.UserId) && user == null) { @@ -724,7 +724,7 @@ namespace MediaBrowser.Server.Implementations.Channels { var user = string.IsNullOrWhiteSpace(query.UserId) ? null - : _userManager.GetUserById(new Guid(query.UserId)); + : _userManager.GetUserById(query.UserId); var channels = GetAllChannels(); @@ -897,7 +897,7 @@ namespace MediaBrowser.Server.Implementations.Channels var user = string.IsNullOrWhiteSpace(query.UserId) ? null - : _userManager.GetUserById(new Guid(query.UserId)); + : _userManager.GetUserById(query.UserId); ChannelItemSortField? sortField = null; ChannelItemSortField parsedField; @@ -942,7 +942,7 @@ namespace MediaBrowser.Server.Implementations.Channels { var user = string.IsNullOrWhiteSpace(query.UserId) ? null - : _userManager.GetUserById(new Guid(query.UserId)); + : _userManager.GetUserById(query.UserId); var internalResult = await GetChannelItemsInternal(query, cancellationToken).ConfigureAwait(false); @@ -1356,7 +1356,7 @@ namespace MediaBrowser.Server.Implementations.Channels public async Task GetChannelFolder(string userId, CancellationToken cancellationToken) { - var user = string.IsNullOrEmpty(userId) ? null : _userManager.GetUserById(new Guid(userId)); + var user = string.IsNullOrEmpty(userId) ? null : _userManager.GetUserById(userId); // Get everything var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList(); diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectData.cs b/MediaBrowser.Server.Implementations/Connect/ConnectData.cs index 1816b103e..dfbeccd4d 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectData.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectData.cs @@ -1,4 +1,6 @@ - +using System; +using System.Collections.Generic; + namespace MediaBrowser.Server.Implementations.Connect { public class ConnectData @@ -13,5 +15,27 @@ namespace MediaBrowser.Server.Implementations.Connect /// /// The access key. public string AccessKey { get; set; } + + /// + /// Gets or sets the authorizations. + /// + /// The authorizations. + public List Authorizations { get; set; } + + public ConnectData() + { + Authorizations = new List(); + } + } + + public class ConnectAuthorization + { + public string LocalUserId { get; set; } + public string AccessToken { get; set; } + + public ConnectAuthorization() + { + AccessToken = new Guid().ToString("N"); + } } } diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs index 3ea54835d..e3e1b39cc 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs @@ -3,6 +3,8 @@ using MediaBrowser.Common.Net; using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Connect; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Security; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Net; @@ -27,9 +29,18 @@ namespace MediaBrowser.Server.Implementations.Connect private readonly IHttpClient _httpClient; private readonly IServerApplicationHost _appHost; private readonly IServerConfigurationManager _config; + private readonly IUserManager _userManager; - public string ConnectServerId { get; set; } - public string ConnectAccessKey { get; set; } + private ConnectData _data = new ConnectData(); + + public string ConnectServerId + { + get { return _data.ServerId; } + } + public string ConnectAccessKey + { + get { return _data.AccessKey; } + } public string DiscoveredWanIpAddress { get; private set; } @@ -47,7 +58,7 @@ namespace MediaBrowser.Server.Implementations.Connect return address; } } - + public string WanApiAddress { get @@ -75,7 +86,7 @@ namespace MediaBrowser.Server.Implementations.Connect IEncryptionManager encryption, IHttpClient httpClient, IServerApplicationHost appHost, - IServerConfigurationManager config) + IServerConfigurationManager config, IUserManager userManager) { _logger = logger; _appPaths = appPaths; @@ -84,6 +95,7 @@ namespace MediaBrowser.Server.Implementations.Connect _httpClient = httpClient; _appHost = appHost; _config = config; + _userManager = userManager; LoadCachedData(); } @@ -156,8 +168,8 @@ namespace MediaBrowser.Server.Implementations.Connect { var data = _json.DeserializeFromStream(stream); - ConnectServerId = data.Id; - ConnectAccessKey = data.AccessKey; + _data.ServerId = data.Id; + _data.AccessKey = data.AccessKey; CacheData(); } @@ -182,7 +194,7 @@ namespace MediaBrowser.Server.Implementations.Connect {"systemid", _appHost.SystemId} }); - options.RequestHeaders.Add("X-Connect-Token", ConnectAccessKey); + SetServerAccessToken(options); // No need to examine the response using (var stream = (await _httpClient.Post(options).ConfigureAwait(false)).Content) @@ -203,11 +215,7 @@ namespace MediaBrowser.Server.Implementations.Connect { Directory.CreateDirectory(Path.GetDirectoryName(path)); - var json = _json.SerializeToString(new ConnectData - { - AccessKey = ConnectAccessKey, - ServerId = ConnectServerId - }); + var json = _json.SerializeToString(_data); var encrypted = _encryption.EncryptString(json); @@ -229,10 +237,7 @@ namespace MediaBrowser.Server.Implementations.Connect var json = _encryption.DecryptString(encrypted); - var data = _json.DeserializeFromString(json); - - ConnectAccessKey = data.AccessKey; - ConnectServerId = data.ServerId; + _data = _json.DeserializeFromString(json); } catch (IOException) { @@ -244,9 +249,181 @@ namespace MediaBrowser.Server.Implementations.Connect } } + private User GetUser(string id) + { + var user = _userManager.GetUserById(id); + + if (user == null) + { + throw new ArgumentException("User not found."); + } + + return user; + } + + public ConnectUserLink GetUserInfo(string userId) + { + var user = GetUser(userId); + + return new ConnectUserLink + { + LocalUserId = user.Id.ToString("N"), + Username = user.ConnectUserName, + UserId = user.ConnectUserId + }; + } + private string GetConnectUrl(string handler) { return "http://mb3admin.com/test/connect/" + handler; } + + public async Task LinkUser(string userId, string connectUsername) + { + if (string.IsNullOrWhiteSpace(connectUsername)) + { + throw new ArgumentNullException("connectUsername"); + } + + var connectUser = await GetConnectUser(new ConnectUserQuery + { + Name = connectUsername + + }, CancellationToken.None).ConfigureAwait(false); + + var user = GetUser(userId); + + // See if it's already been set. + if (string.Equals(connectUser.Id, user.ConnectUserId, StringComparison.OrdinalIgnoreCase)) + { + return; + } + + if (!string.IsNullOrWhiteSpace(user.ConnectUserId)) + { + await RemoveLink(user, connectUser).ConfigureAwait(false); + } + + var url = GetConnectUrl("ServerAuthorizations"); + + var options = new HttpRequestOptions + { + Url = url, + CancellationToken = CancellationToken.None + }; + + var accessToken = Guid.NewGuid().ToString("N"); + + var postData = new Dictionary + { + {"serverId", ConnectServerId}, + {"userId", connectUser.Id}, + {"userType", "Linked"}, + {"accessToken", accessToken} + }; + + options.SetPostData(postData); + + SetServerAccessToken(options); + + // No need to examine the response + using (var stream = (await _httpClient.Post(options).ConfigureAwait(false)).Content) + { + } + + user.ConnectAccessKey = accessToken; + user.ConnectUserName = connectUser.Name; + user.ConnectUserId = connectUser.Id; + + await user.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); + } + + public async Task RemoveLink(string userId) + { + var user = GetUser(userId); + + var connectUser = await GetConnectUser(new ConnectUserQuery + { + Name = user.ConnectUserId + + }, CancellationToken.None).ConfigureAwait(false); + + await RemoveLink(user, connectUser).ConfigureAwait(false); + } + + public async Task RemoveLink(User user, ConnectUser connectUser) + { + var url = GetConnectUrl("ServerAuthorizations"); + + var options = new HttpRequestOptions + { + Url = url, + CancellationToken = CancellationToken.None + }; + + var postData = new Dictionary + { + {"serverId", ConnectServerId}, + {"userId", connectUser.Id} + }; + + options.SetPostData(postData); + + SetServerAccessToken(options); + + // No need to examine the response + using (var stream = (await _httpClient.SendAsync(options, "DELETE").ConfigureAwait(false)).Content) + { + } + + user.ConnectAccessKey = null; + user.ConnectUserName = null; + user.ConnectUserId = null; + + await user.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); + } + + private async Task GetConnectUser(ConnectUserQuery query, CancellationToken cancellationToken) + { + var url = GetConnectUrl("user"); + + if (!string.IsNullOrWhiteSpace(query.Id)) + { + url = url + "?id=" + WebUtility.UrlEncode(query.Id); + } + else if (!string.IsNullOrWhiteSpace(query.Name)) + { + url = url + "?name=" + WebUtility.UrlEncode(query.Name); + } + else if (!string.IsNullOrWhiteSpace(query.Email)) + { + url = url + "?email=" + WebUtility.UrlEncode(query.Email); + } + + var options = new HttpRequestOptions + { + CancellationToken = cancellationToken, + Url = url + }; + + SetServerAccessToken(options); + + using (var stream = await _httpClient.Get(options).ConfigureAwait(false)) + { + var response = _json.DeserializeFromStream(stream); + + return new ConnectUser + { + Email = response.Email, + Id = response.Id, + Name = response.Name + }; + } + } + + private void SetServerAccessToken(HttpRequestOptions options) + { + options.RequestHeaders.Add("X-Connect-Token", ConnectAccessKey); + } } } diff --git a/MediaBrowser.Server.Implementations/Connect/Responses.cs b/MediaBrowser.Server.Implementations/Connect/Responses.cs new file mode 100644 index 000000000..5d71c0f9b --- /dev/null +++ b/MediaBrowser.Server.Implementations/Connect/Responses.cs @@ -0,0 +1,28 @@ + +namespace MediaBrowser.Server.Implementations.Connect +{ + public class ServerRegistrationResponse + { + public string Id { get; set; } + public string Url { get; set; } + public string Name { get; set; } + public string AccessKey { get; set; } + } + + public class UpdateServerRegistrationResponse + { + public string Id { get; set; } + public string Url { get; set; } + public string Name { get; set; } + } + + public class GetConnectUserResponse + { + public string Id { get; set; } + public string Name { get; set; } + public string DisplayName { get; set; } + public string Email { get; set; } + public string IsActive { get; set; } + public string ImageUrl { get; set; } + } +} diff --git a/MediaBrowser.Server.Implementations/Connect/ServerRegistrationResponse.cs b/MediaBrowser.Server.Implementations/Connect/ServerRegistrationResponse.cs deleted file mode 100644 index 75c55e26e..000000000 --- a/MediaBrowser.Server.Implementations/Connect/ServerRegistrationResponse.cs +++ /dev/null @@ -1,18 +0,0 @@ - -namespace MediaBrowser.Server.Implementations.Connect -{ - public class ServerRegistrationResponse - { - public string Id { get; set; } - public string Url { get; set; } - public string Name { get; set; } - public string AccessKey { get; set; } - } - - public class UpdateServerRegistrationResponse - { - public string Id { get; set; } - public string Url { get; set; } - public string Name { get; set; } - } -} diff --git a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs index 1294368f1..ea0982491 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs @@ -69,7 +69,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security var user = string.IsNullOrWhiteSpace(auth.UserId) ? null - : UserManager.GetUserById(new Guid(auth.UserId)); + : UserManager.GetUserById(auth.UserId); if (user == null & !string.IsNullOrWhiteSpace(auth.UserId)) { diff --git a/MediaBrowser.Server.Implementations/Library/SearchEngine.cs b/MediaBrowser.Server.Implementations/Library/SearchEngine.cs index 6faa72b81..738222540 100644 --- a/MediaBrowser.Server.Implementations/Library/SearchEngine.cs +++ b/MediaBrowser.Server.Implementations/Library/SearchEngine.cs @@ -39,7 +39,7 @@ namespace MediaBrowser.Server.Implementations.Library } else { - var user = _userManager.GetUserById(new Guid(query.UserId)); + var user = _userManager.GetUserById(query.UserId); inputItems = user.RootFolder.GetRecursiveChildren(user, true); } diff --git a/MediaBrowser.Server.Implementations/Library/UserManager.cs b/MediaBrowser.Server.Implementations/Library/UserManager.cs index 94cc61240..47d6b17f0 100644 --- a/MediaBrowser.Server.Implementations/Library/UserManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserManager.cs @@ -128,6 +128,16 @@ namespace MediaBrowser.Server.Implementations.Library return Users.FirstOrDefault(u => u.Id == id); } + /// + /// Gets the user by identifier. + /// + /// The identifier. + /// User. + public User GetUserById(string id) + { + return GetUserById(new Guid(id)); + } + public async Task Initialize() { Users = await LoadUsers().ConfigureAwait(false); @@ -219,6 +229,9 @@ namespace MediaBrowser.Server.Implementations.Library await UserRepository.SaveUser(user, CancellationToken.None).ConfigureAwait(false); users.Add(user); + + user.Configuration.IsAdministrator = true; + UpdateConfiguration(user, user.Configuration); } return users; @@ -503,7 +516,8 @@ namespace MediaBrowser.Server.Implementations.Library Name = name, Id = ("MBUser" + name).GetMD5(), DateCreated = DateTime.UtcNow, - DateModified = DateTime.UtcNow + DateModified = DateTime.UtcNow, + UsesIdForConfigurationPath = true }; } diff --git a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs index 61283505b..4beb34e4f 100644 --- a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs @@ -47,7 +47,7 @@ namespace MediaBrowser.Server.Implementations.Library public async Task> GetUserViews(UserViewQuery query, CancellationToken cancellationToken) { - var user = _userManager.GetUserById(new Guid(query.UserId)); + var user = _userManager.GetUserById(query.UserId); var folders = user.RootFolder .GetChildren(user, true) diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index d2a89e947..562b97a48 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -133,7 +133,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv public async Task> GetInternalChannels(LiveTvChannelQuery query, CancellationToken cancellationToken) { - var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(new Guid(query.UserId)); + var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId); var channels = _channelIdList.Select(_libraryManager.GetItemById) .Where(i => i != null) @@ -231,7 +231,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv public async Task> GetChannels(LiveTvChannelQuery query, CancellationToken cancellationToken) { - var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(new Guid(query.UserId)); + var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId); var internalResult = await GetInternalChannels(query, cancellationToken).ConfigureAwait(false); @@ -693,7 +693,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv }); } - var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(new Guid(query.UserId)); + var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId); if (user != null) { @@ -730,7 +730,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv { IEnumerable programs = _programs.Values; - var user = _userManager.GetUserById(new Guid(query.UserId)); + var user = _userManager.GetUserById(query.UserId); // Avoid implicitly captured closure var currentUser = user; @@ -786,7 +786,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv { var internalResult = await GetRecommendedProgramsInternal(query, cancellationToken).ConfigureAwait(false); - var user = _userManager.GetUserById(new Guid(query.UserId)); + var user = _userManager.GetUserById(query.UserId); var returnArray = internalResult.Items .Select(i => @@ -1099,7 +1099,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv }; } - var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(new Guid(query.UserId)); + var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId); var recordings = await service.GetRecordingsAsync(cancellationToken).ConfigureAwait(false); @@ -1199,7 +1199,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv }; } - var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(new Guid(query.UserId)); + var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId); var internalResult = await GetInternalRecordings(query, cancellationToken).ConfigureAwait(false); @@ -1869,7 +1869,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv public async Task GetLiveTvFolder(string userId, CancellationToken cancellationToken) { - var user = string.IsNullOrEmpty(userId) ? null : _userManager.GetUserById(new Guid(userId)); + var user = string.IsNullOrEmpty(userId) ? null : _userManager.GetUserById(userId); // Get everything var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList(); diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index c1d4a42c9..f95fd85b7 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -11,7 +11,7 @@ "FileNotFound": "File not found.", "FileReadError": "An error occurred while reading the file.", "DeleteUser": "Delete User", - "DeleteUserConfirmation": "Are you sure you wish to delete {0}?", + "DeleteUserConfirmation": "Are you sure you wish to delete this user?", "PasswordResetHeader": "Password Reset", "PasswordResetComplete": "The password has been reset.", "PasswordResetConfirmation": "Are you sure you wish to reset the password?", @@ -450,5 +450,8 @@ "MessageChangeRecurringPlanConfirm": "After completing this transaction you will need to cancel your previous recurring donation from within your PayPal account. Thank you for supporting Media Browser.", "MessageSupporterMembershipExpiredOn": "Your supporter membership expired on {0}.", "MessageYouHaveALifetimeMembership": "You have a lifetime supporter membership. You can provide additional donations on a one-time or recurring basis using the options below. Thank you for supporting Media Browser.", - "MessageYouHaveAnActiveRecurringMembership": "You have an active {0} membership. You can upgrade your plan using the options below." + "MessageYouHaveAnActiveRecurringMembership": "You have an active {0} membership. You can upgrade your plan using the options below.", + "ButtonDelete": "Delete", + "HeaderMediaBrowserAccountAdded": "Media Browser Account Added", + "MessageMediaBrowserAccontAdded": "A Media Browser account has been added to this user. An email has been sent to the owner of the account. They will need to confirm the invitation by clicking a link within the email." } diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index f5e54e3f9..7a3b08def 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -74,6 +74,8 @@ "TabProfiles": "Profiles", "TabSecurity": "Security", "ButtonAddUser": "Add User", + "ButtonAddLocalUser": "Add Local User", + "ButtonInviteMediaBrowserUser": "Invite Media Browser User", "ButtonSave": "Save", "ButtonResetPassword": "Reset Password", "LabelNewPassword": "New password:", @@ -1156,5 +1158,7 @@ "XmlDocumentAttributeListHelp": "These attributes are applied to the root element of every xml response.", "OptionSaveMetadataAsHidden": "Save metadata and images as hidden files", "LabelExtractChaptersDuringLibraryScan": "Extract chapter images during the library scan", - "LabelExtractChaptersDuringLibraryScanHelp": "If enabled, chapter images will be extracted when videos are imported during the library scan. If disabled they will be extracted during the chapter images scheduled task, allowing the regular library scan to complete faster." + "LabelExtractChaptersDuringLibraryScanHelp": "If enabled, chapter images will be extracted when videos are imported during the library scan. If disabled they will be extracted during the chapter images scheduled task, allowing the regular library scan to complete faster.", + "LabelConnectUserName": "Media Browser username/email:", + "LabelConnectUserNameHelp": "Connect this user to a Media Browser account to enable easy sign-in access from any app without having to know the server ip address." } diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index b44adc4d8..d7c06e2f4 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -118,7 +118,7 @@ - + diff --git a/MediaBrowser.Server.Implementations/Notifications/NotificationManager.cs b/MediaBrowser.Server.Implementations/Notifications/NotificationManager.cs index 3558922d8..3f8b61a45 100644 --- a/MediaBrowser.Server.Implementations/Notifications/NotificationManager.cs +++ b/MediaBrowser.Server.Implementations/Notifications/NotificationManager.cs @@ -44,7 +44,7 @@ namespace MediaBrowser.Server.Implementations.Notifications GetConfiguration().GetOptions(notificationType); var users = GetUserIds(request, options) - .Select(i => _userManager.GetUserById(new Guid(i))); + .Select(i => _userManager.GetUserById(i)); var title = GetTitle(request, options); var description = GetDescription(request, options); diff --git a/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs b/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs index ee2114aa4..852959312 100644 --- a/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs +++ b/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs @@ -35,7 +35,7 @@ namespace MediaBrowser.Server.Implementations.Playlists public IEnumerable GetPlaylists(string userId) { - var user = _userManager.GetUserById(new Guid(userId)); + var user = _userManager.GetUserById(userId); return GetPlaylistsFolder(userId).GetChildren(user, true).OfType(); } @@ -100,7 +100,7 @@ namespace MediaBrowser.Server.Implementations.Playlists throw new ArgumentException("A playlist media type is required."); } - var user = _userManager.GetUserById(new Guid(options.UserId)); + var user = _userManager.GetUserById(options.UserId); var path = Path.Combine(parentFolder.Path, folderName); path = GetTargetPath(path); @@ -162,7 +162,7 @@ namespace MediaBrowser.Server.Implementations.Playlists public Task AddToPlaylist(string playlistId, IEnumerable itemIds, string userId) { - var user = string.IsNullOrWhiteSpace(userId) ? null : _userManager.GetUserById(new Guid(userId)); + var user = string.IsNullOrWhiteSpace(userId) ? null : _userManager.GetUserById(userId); return AddToPlaylistInternal(playlistId, itemIds, user); } diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index 912174c1e..ceda8f47d 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -455,7 +455,7 @@ namespace MediaBrowser.Server.Implementations.Session users.Add(user); var additionalUsers = session.AdditionalUsers - .Select(i => _userManager.GetUserById(new Guid(i.UserId))) + .Select(i => _userManager.GetUserById(i.UserId)) .Where(i => i != null); users.AddRange(additionalUsers); @@ -1189,7 +1189,7 @@ namespace MediaBrowser.Server.Implementations.Session if (!string.IsNullOrWhiteSpace(info.UserId)) { - var user = _userManager.GetUserById(new Guid(info.UserId)); + var user = _userManager.GetUserById(info.UserId); if (user == null || user.Configuration.IsDisabled) { diff --git a/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs b/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs index e71a5d514..66e771aa3 100644 --- a/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs +++ b/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs @@ -25,7 +25,7 @@ namespace MediaBrowser.Server.Implementations.TV public QueryResult GetNextUp(NextUpQuery request) { - var user = _userManager.GetUserById(new Guid(request.UserId)); + var user = _userManager.GetUserById(request.UserId); if (user == null) { @@ -47,7 +47,7 @@ namespace MediaBrowser.Server.Implementations.TV public QueryResult GetNextUp(NextUpQuery request, IEnumerable parentsFolders) { - var user = _userManager.GetUserById(new Guid(request.UserId)); + var user = _userManager.GetUserById(request.UserId); if (user == null) { -- cgit v1.2.3