From 1d70f5469f68c1f576bad85ff35930b593e955de Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 14 Oct 2014 00:22:17 -0400 Subject: [PATCH] update connect --- MediaBrowser.Api/ConnectService.cs | 2 +- .../Playback/BaseStreamingService.cs | 9 +- MediaBrowser.Api/UserService.cs | 1 + .../Connect/IConnectManager.cs | 2 +- MediaBrowser.Controller/Entities/User.cs | 2 +- MediaBrowser.Controller/Entities/Video.cs | 1 + .../Library/IUserManager.cs | 6 +- .../Resolvers/BaseVideoResolver.cs | 13 +- MediaBrowser.Model/Dto/UserDto.cs | 2 +- .../Manager/MetadataService.cs | 4 +- .../MediaInfo/FFProbeProvider.cs | 2 +- .../MediaInfo/VideoImageProvider.cs | 4 +- .../Connect/ConnectData.cs | 7 + .../Connect/ConnectManager.cs | 133 ++++++++++-------- .../Library/UserManager.cs | 20 ++- .../Localization/JavaScript/javascript.json | 2 +- .../Localization/Server/server.json | 7 +- .../ApplicationHost.cs | 2 +- 18 files changed, 135 insertions(+), 84 deletions(-) diff --git a/MediaBrowser.Api/ConnectService.cs b/MediaBrowser.Api/ConnectService.cs index 3a863316ba..5a2c04ab6b 100644 --- a/MediaBrowser.Api/ConnectService.cs +++ b/MediaBrowser.Api/ConnectService.cs @@ -70,7 +70,7 @@ namespace MediaBrowser.Api public void Delete(DeleteConnectLink request) { - var task = _connectManager.RemoveLink(request.Id); + var task = _connectManager.RemoveConnect(request.Id); Task.WaitAll(task); } diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 8b53954884..fa6f88cc41 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -1591,7 +1591,9 @@ namespace MediaBrowser.Api.Playback state.InputFileSize = mediaSource.Size; state.InputBitrate = mediaSource.Bitrate; - if (item is Video) + var video = item as Video; + + if (video != null) { state.IsInputVideo = true; @@ -1608,6 +1610,11 @@ namespace MediaBrowser.Api.Playback { state.InputTimestamp = mediaSource.Timestamp.Value; } + + if (video.IsShortcut) + { + state.MediaPath = File.ReadAllText(video.Path); + } } state.RunTimeTicks = mediaSource.RunTimeTicks; diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index 10595d926c..a30ecf7d6a 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -290,6 +290,7 @@ namespace MediaBrowser.Api } await _sessionMananger.RevokeUserTokens(user.Id.ToString("N")).ConfigureAwait(false); + await _userManager.DeleteUser(user).ConfigureAwait(false); } diff --git a/MediaBrowser.Controller/Connect/IConnectManager.cs b/MediaBrowser.Controller/Connect/IConnectManager.cs index afb61cb239..8bd0332c01 100644 --- a/MediaBrowser.Controller/Connect/IConnectManager.cs +++ b/MediaBrowser.Controller/Connect/IConnectManager.cs @@ -25,7 +25,7 @@ namespace MediaBrowser.Controller.Connect /// /// The user identifier. /// Task. - Task RemoveLink(string userId); + Task RemoveConnect(string userId); /// /// Invites the user. diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index e0682c9ee9..2275cbad42 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -35,7 +35,7 @@ namespace MediaBrowser.Controller.Entities public string ConnectUserName { get; set; } public string ConnectUserId { get; set; } - public UserLinkType ConnectLinkType { get; set; } + public UserLinkType? ConnectLinkType { get; set; } public string ConnectAccessKey { get; set; } /// diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 59649de7f8..dc9769d53f 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -128,6 +128,7 @@ namespace MediaBrowser.Controller.Entities public bool HasSubtitles { get; set; } public bool IsPlaceHolder { get; set; } + public bool IsShortcut { get; set; } /// /// Gets or sets the tags. diff --git a/MediaBrowser.Controller/Library/IUserManager.cs b/MediaBrowser.Controller/Library/IUserManager.cs index 3efdbea768..39ec2b85d1 100644 --- a/MediaBrowser.Controller/Library/IUserManager.cs +++ b/MediaBrowser.Controller/Library/IUserManager.cs @@ -55,16 +55,16 @@ namespace MediaBrowser.Controller.Library /// The identifier. /// User. User GetUserById(string id); - + /// /// Authenticates a User and returns a result indicating whether or not it succeeded /// /// The username. - /// The password. + /// The password sha1. /// The remote end point. /// Task{System.Boolean}. /// user - Task AuthenticateUser(string username, string password, string remoteEndPoint); + Task AuthenticateUser(string username, string passwordSha1, string remoteEndPoint); /// /// Refreshes metadata for each user diff --git a/MediaBrowser.Controller/Resolvers/BaseVideoResolver.cs b/MediaBrowser.Controller/Resolvers/BaseVideoResolver.cs index 038d8d48bf..5725c64828 100644 --- a/MediaBrowser.Controller/Resolvers/BaseVideoResolver.cs +++ b/MediaBrowser.Controller/Resolvers/BaseVideoResolver.cs @@ -38,19 +38,24 @@ namespace MediaBrowser.Controller.Resolvers // http://wiki.xbmc.org/index.php?title=Media_stubs var isPlaceHolder = EntityResolutionHelper.IsVideoPlaceHolder(args.Path); - if (EntityResolutionHelper.IsVideoFile(args.Path) || isPlaceHolder) - { - var extension = Path.GetExtension(args.Path); + var extension = Path.GetExtension(args.Path); + + var isShortcut = string.Equals(extension, ".strm", StringComparison.OrdinalIgnoreCase); + if (EntityResolutionHelper.IsVideoFile(args.Path) || isPlaceHolder || isShortcut) + { var type = string.Equals(extension, ".iso", StringComparison.OrdinalIgnoreCase) || string.Equals(extension, ".img", StringComparison.OrdinalIgnoreCase) ? VideoType.Iso : VideoType.VideoFile; + var path = args.Path; + var video = new TVideoType { VideoType = type, Path = args.Path, IsInMixedFolder = true, - IsPlaceHolder = isPlaceHolder + IsPlaceHolder = isPlaceHolder, + IsShortcut = isShortcut }; if (isPlaceHolder) diff --git a/MediaBrowser.Model/Dto/UserDto.cs b/MediaBrowser.Model/Dto/UserDto.cs index b88e9d411a..007c634b6e 100644 --- a/MediaBrowser.Model/Dto/UserDto.cs +++ b/MediaBrowser.Model/Dto/UserDto.cs @@ -34,7 +34,7 @@ namespace MediaBrowser.Model.Dto /// Gets or sets the type of the connect link. /// /// The type of the connect link. - public UserLinkType ConnectLinkType { get; set; } + public UserLinkType? ConnectLinkType { get; set; } /// /// Gets or sets the id. diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index 35e6befbb8..2fdbe67404 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -146,7 +146,7 @@ namespace MediaBrowser.Providers.Manager updateType = updateType | result.UpdateType; refreshResult.AddStatus(result.Status, result.ErrorMessage); refreshResult.SetDateLastMetadataRefresh(DateTime.UtcNow); - refreshResult.AddImageProvidersRefreshed(result.Providers); + refreshResult.AddMetadataProvidersRefreshed(result.Providers); MergeIdentities(itemOfType, id); } @@ -479,7 +479,7 @@ namespace MediaBrowser.Providers.Manager } catch (Exception ex) { - refreshResult.Status = ProviderRefreshStatus.CompletedWithErrors; + refreshResult.Status = ProviderRefreshStatus.Failure; refreshResult.ErrorMessage = ex.Message; Logger.ErrorException("Error in {0}", ex, provider.Name); } diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs b/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs index ad5fad34ae..cc161803ab 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs @@ -132,7 +132,7 @@ namespace MediaBrowser.Providers.MediaInfo return _cachedTask; } - if (item.IsPlaceHolder) + if (item.IsPlaceHolder || item.IsShortcut) { return _cachedTask; } diff --git a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs index 7d0677ae1c..78a294e5f0 100644 --- a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs @@ -121,7 +121,9 @@ namespace MediaBrowser.Providers.MediaInfo public bool Supports(IHasImages item) { - return item.LocationType == LocationType.FileSystem && item is Video; + var video = item as Video; + + return item.LocationType == LocationType.FileSystem && video != null && !video.IsPlaceHolder && !video.IsShortcut; } public int Order diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectData.cs b/MediaBrowser.Server.Implementations/Connect/ConnectData.cs index e26fdc6076..87d59f3566 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectData.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectData.cs @@ -1,4 +1,5 @@ using MediaBrowser.Model.Connect; +using System; using System.Collections.Generic; namespace MediaBrowser.Server.Implementations.Connect @@ -22,6 +23,12 @@ namespace MediaBrowser.Server.Implementations.Connect /// The authorizations. public List PendingAuthorizations { get; set; } + /// + /// Gets or sets the last authorizations refresh. + /// + /// The last authorizations refresh. + public DateTime LastAuthorizationsRefresh { get; set; } + public ConnectData() { PendingAuthorizations = new List(); diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs index 92b769f3b9..40d9119798 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs @@ -168,9 +168,7 @@ namespace MediaBrowser.Server.Implementations.Connect await CreateServerRegistration(wanApiAddress).ConfigureAwait(false); } - await RefreshAuthorizationsInternal(CancellationToken.None).ConfigureAwait(false); - - await RefreshUserInfosInternal(CancellationToken.None).ConfigureAwait(false); + await RefreshAuthorizationsInternal(true, CancellationToken.None).ConfigureAwait(false); } catch (Exception ex) { @@ -335,7 +333,7 @@ namespace MediaBrowser.Server.Implementations.Connect if (!string.IsNullOrWhiteSpace(user.ConnectUserId)) { - await RemoveLink(user, connectUser.Id).ConfigureAwait(false); + await RemoveConnect(user, connectUser.Id).ConfigureAwait(false); } var url = GetConnectUrl("ServerAuthorizations"); @@ -377,15 +375,15 @@ namespace MediaBrowser.Server.Implementations.Connect await user.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); - user.Configuration.SyncConnectImage = user.ConnectLinkType == UserLinkType.Guest; - user.Configuration.SyncConnectName = user.ConnectLinkType == UserLinkType.Guest; + user.Configuration.SyncConnectImage = false; + user.Configuration.SyncConnectName = false; _userManager.UpdateConfiguration(user, user.Configuration); - await RefreshAuthorizationsInternal(CancellationToken.None).ConfigureAwait(false); + await RefreshAuthorizationsInternal(false, CancellationToken.None).ConfigureAwait(false); return result; } - + public async Task InviteUser(string sendingUserId, string connectUsername) { await _operationLock.WaitAsync().ConfigureAwait(false); @@ -452,19 +450,19 @@ namespace MediaBrowser.Server.Implementations.Connect result.IsPending = string.Equals(response.AcceptStatus, "waiting", StringComparison.OrdinalIgnoreCase); } - await RefreshAuthorizationsInternal(CancellationToken.None).ConfigureAwait(false); + await RefreshAuthorizationsInternal(false, CancellationToken.None).ConfigureAwait(false); return result; } - - public Task RemoveLink(string userId) + + public Task RemoveConnect(string userId) { var user = GetUser(userId); - return RemoveLink(user, user.ConnectUserId); + return RemoveConnect(user, user.ConnectUserId); } - private async Task RemoveLink(User user, string connectUserId) + private async Task RemoveConnect(User user, string connectUserId) { if (!string.IsNullOrWhiteSpace(connectUserId)) { @@ -474,7 +472,7 @@ namespace MediaBrowser.Server.Implementations.Connect user.ConnectAccessKey = null; user.ConnectUserName = null; user.ConnectUserId = null; - user.ConnectLinkType = UserLinkType.LinkedUser; + user.ConnectLinkType = null; await user.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); } @@ -513,7 +511,8 @@ namespace MediaBrowser.Server.Implementations.Connect Email = response.Email, Id = response.Id, Name = response.Name, - IsActive = response.IsActive + IsActive = response.IsActive, + ImageUrl = response.ImageUrl }; } } @@ -529,7 +528,7 @@ namespace MediaBrowser.Server.Implementations.Connect try { - await RefreshAuthorizationsInternal(cancellationToken).ConfigureAwait(false); + await RefreshAuthorizationsInternal(true, cancellationToken).ConfigureAwait(false); } finally { @@ -537,7 +536,7 @@ namespace MediaBrowser.Server.Implementations.Connect } } - private async Task RefreshAuthorizationsInternal(CancellationToken cancellationToken) + private async Task RefreshAuthorizationsInternal(bool refreshImages, CancellationToken cancellationToken) { var url = GetConnectUrl("ServerAuthorizations"); @@ -557,7 +556,7 @@ namespace MediaBrowser.Server.Implementations.Connect { var list = _json.DeserializeFromStream>(stream); - await RefreshAuthorizations(list).ConfigureAwait(false); + await RefreshAuthorizations(list, refreshImages).ConfigureAwait(false); } } catch (Exception ex) @@ -566,7 +565,8 @@ namespace MediaBrowser.Server.Implementations.Connect } } - private async Task RefreshAuthorizations(List list) + private readonly SemaphoreSlim _connectImageSemaphore = new SemaphoreSlim(5, 5); + private async Task RefreshAuthorizations(List list, bool refreshImages) { var users = _userManager.Users.ToList(); @@ -583,13 +583,14 @@ namespace MediaBrowser.Server.Implementations.Connect user.ConnectUserId = null; user.ConnectAccessKey = null; user.ConnectUserName = null; + user.ConnectLinkType = null; await _userManager.UpdateUser(user).ConfigureAwait(false); - if (user.ConnectLinkType == UserLinkType.Guest) + if (user.ConnectLinkType.HasValue && user.ConnectLinkType.Value == UserLinkType.Guest) { _logger.Debug("Deleting guest user {0}", user.Name); - //await _userManager.DeleteUser(user).ConfigureAwait(false); + await _userManager.DeleteUser(user).ConfigureAwait(false); } } else @@ -611,7 +612,6 @@ namespace MediaBrowser.Server.Implementations.Connect var pending = new List(); - // TODO: Handle newly added guests that we don't know about foreach (var connectEntry in list) { if (string.Equals(connectEntry.UserType, "guest", StringComparison.OrdinalIgnoreCase)) @@ -623,18 +623,29 @@ namespace MediaBrowser.Server.Implementations.Connect if (user == null) { // Add user - //user.Configuration.SyncConnectImage = user.ConnectLinkType == UserLinkType.Guest; - //user.Configuration.SyncConnectName = user.ConnectLinkType == UserLinkType.Guest; + user = await _userManager.CreateUser(connectEntry.UserName).ConfigureAwait(false); + + user.ConnectUserName = connectEntry.UserName; + user.ConnectUserId = connectEntry.UserId; + user.ConnectLinkType = UserLinkType.Guest; + user.ConnectAccessKey = connectEntry.AccessToken; + + await _userManager.UpdateUser(user).ConfigureAwait(false); + + user.Configuration.SyncConnectImage = true; + user.Configuration.SyncConnectName = true; + + _userManager.UpdateConfiguration(user, user.Configuration); } } else if (string.Equals(connectEntry.AcceptStatus, "waiting", StringComparison.OrdinalIgnoreCase)) { pending.Add(new ConnectAuthorization { - ConnectUserId = connectEntry.UserId, - ImageUrl = connectEntry.UserImageUrl, - UserName = connectEntry.UserName, - Id = connectEntry.Id + ConnectUserId = connectEntry.UserId, + ImageUrl = connectEntry.UserImageUrl, + UserName = connectEntry.UserName, + Id = connectEntry.Id }); } } @@ -642,54 +653,40 @@ namespace MediaBrowser.Server.Implementations.Connect _data.PendingAuthorizations = pending; CacheData(); - } - public async Task RefreshUserInfos(CancellationToken cancellationToken) - { - await _operationLock.WaitAsync(cancellationToken).ConfigureAwait(false); - - try - { - await RefreshUserInfosInternal(cancellationToken).ConfigureAwait(false); - } - finally - { - _operationLock.Release(); - } + await RefreshGuestNames(list, refreshImages).ConfigureAwait(false); } - private readonly SemaphoreSlim _connectImageSemaphore = new SemaphoreSlim(5, 5); - - private async Task RefreshUserInfosInternal(CancellationToken cancellationToken) + private async Task RefreshGuestNames(List list, bool refreshImages) { var users = _userManager.Users .Where(i => !string.IsNullOrEmpty(i.ConnectUserId) && (i.Configuration.SyncConnectImage || i.Configuration.SyncConnectName)) - .ToList(); + .ToList(); foreach (var user in users) { - cancellationToken.ThrowIfCancellationRequested(); + var authorization = list.FirstOrDefault(i => string.Equals(i.UserId, user.ConnectUserId, StringComparison.Ordinal)); - var connectUser = await GetConnectUser(new ConnectUserQuery + if (authorization == null) { - Id = user.ConnectUserId - - }, cancellationToken).ConfigureAwait(false); + _logger.Warn("Unable to find connect authorization record for user {0}", user.Name); + continue; + } if (user.Configuration.SyncConnectName) { - var changed = !string.Equals(connectUser.Name, user.Name, StringComparison.OrdinalIgnoreCase); + var changed = !string.Equals(authorization.UserName, user.Name, StringComparison.OrdinalIgnoreCase); if (changed) { - await user.Rename(connectUser.Name).ConfigureAwait(false); + await user.Rename(authorization.UserName).ConfigureAwait(false); } } if (user.Configuration.SyncConnectImage) { - var imageUrl = connectUser.ImageUrl; + var imageUrl = authorization.UserImageUrl; if (!string.IsNullOrWhiteSpace(imageUrl)) { @@ -699,12 +696,11 @@ namespace MediaBrowser.Server.Implementations.Connect { changed = true; } - else + else if (refreshImages) { using (var response = await _httpClient.SendAsync(new HttpRequestOptions { Url = imageUrl, - CancellationToken = cancellationToken, BufferContent = false }, "HEAD").ConfigureAwait(false)) @@ -720,13 +716,13 @@ namespace MediaBrowser.Server.Implementations.Connect if (changed) { - await _providerManager.SaveImage(user, imageUrl, _connectImageSemaphore, ImageType.Primary, null, cancellationToken).ConfigureAwait(false); - + await _providerManager.SaveImage(user, imageUrl, _connectImageSemaphore, ImageType.Primary, null, CancellationToken.None).ConfigureAwait(false); + await user.RefreshMetadata(new MetadataRefreshOptions { ForceSave = true, - }, cancellationToken).ConfigureAwait(false); + }, CancellationToken.None).ConfigureAwait(false); } } } @@ -735,6 +731,25 @@ namespace MediaBrowser.Server.Implementations.Connect public async Task> GetPendingGuests() { + var time = DateTime.UtcNow - _data.LastAuthorizationsRefresh; + + if (time.TotalMinutes >= 5) + { + await _operationLock.WaitAsync(CancellationToken.None).ConfigureAwait(false); + + try + { + await RefreshAuthorizationsInternal(false, CancellationToken.None).ConfigureAwait(false); + + _data.LastAuthorizationsRefresh = DateTime.UtcNow; + CacheData(); + } + finally + { + _operationLock.Release(); + } + } + return _data.PendingAuthorizations.ToList(); } @@ -760,7 +775,7 @@ namespace MediaBrowser.Server.Implementations.Connect await CancelAuthorizationByConnectUserId(connectUserId).ConfigureAwait(false); - await RefreshAuthorizationsInternal(CancellationToken.None).ConfigureAwait(false); + await RefreshAuthorizationsInternal(false, CancellationToken.None).ConfigureAwait(false); } private async Task CancelAuthorizationByConnectUserId(string connectUserId) diff --git a/MediaBrowser.Server.Implementations/Library/UserManager.cs b/MediaBrowser.Server.Implementations/Library/UserManager.cs index 16a1dc516b..e76bc4f80f 100644 --- a/MediaBrowser.Server.Implementations/Library/UserManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserManager.cs @@ -2,6 +2,7 @@ using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Connect; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; @@ -61,6 +62,7 @@ namespace MediaBrowser.Server.Implementations.Library private readonly Func _imageProcessorFactory; private readonly Func _dtoServiceFactory; + private readonly Func _connectFactory; /// /// Initializes a new instance of the class. @@ -68,7 +70,7 @@ namespace MediaBrowser.Server.Implementations.Library /// The logger. /// The configuration manager. /// The user repository. - public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func imageProcessorFactory, Func dtoServiceFactory) + public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func imageProcessorFactory, Func dtoServiceFactory, Func connectFactory) { _logger = logger; UserRepository = userRepository; @@ -76,6 +78,7 @@ namespace MediaBrowser.Server.Implementations.Library _networkManager = networkManager; _imageProcessorFactory = imageProcessorFactory; _dtoServiceFactory = dtoServiceFactory; + _connectFactory = connectFactory; ConfigurationManager = configurationManager; Users = new List(); } @@ -143,7 +146,7 @@ namespace MediaBrowser.Server.Implementations.Library Users = await LoadUsers().ConfigureAwait(false); } - public async Task AuthenticateUser(string username, string password, string remoteEndPoint) + public async Task AuthenticateUser(string username, string passwordSha1, string remoteEndPoint) { if (string.IsNullOrWhiteSpace(username)) { @@ -157,11 +160,11 @@ namespace MediaBrowser.Server.Implementations.Library throw new AuthenticationException(string.Format("The {0} account is currently disabled. Please consult with your administrator.", user.Name)); } - var success = string.Equals(GetPasswordHash(user), password.Replace("-", string.Empty), StringComparison.OrdinalIgnoreCase); + var success = string.Equals(GetPasswordHash(user), passwordSha1.Replace("-", string.Empty), StringComparison.OrdinalIgnoreCase); if (!success && _networkManager.IsInLocalNetwork(remoteEndPoint) && user.Configuration.EnableLocalPassword) { - success = string.Equals(GetLocalPasswordHash(user), password.Replace("-", string.Empty), StringComparison.OrdinalIgnoreCase); + success = string.Equals(GetLocalPasswordHash(user), passwordSha1.Replace("-", string.Empty), StringComparison.OrdinalIgnoreCase); } // Update LastActivityDate and LastLoginDate, then save @@ -433,6 +436,11 @@ namespace MediaBrowser.Server.Implementations.Library throw new ArgumentNullException("user"); } + if (user.ConnectLinkType.HasValue) + { + await _connectFactory().RemoveConnect(user.Id.ToString("N")).ConfigureAwait(false); + } + var allUsers = Users.ToList(); if (allUsers.FirstOrDefault(u => u.Id == user.Id) == null) @@ -514,10 +522,12 @@ namespace MediaBrowser.Server.Implementations.Library /// User. private User InstantiateNewUser(string name) { + var idSalt = ("MBUser" + name); + return new User { Name = name, - Id = ("MBUser" + name).GetMD5(), + Id = idSalt.GetMD5(), DateCreated = DateTime.UtcNow, DateModified = DateTime.UtcNow, UsesIdForConfigurationPath = true diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index c1e9ff5cd6..ec275c8dc1 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -606,7 +606,7 @@ "TabDevices": "Devices", "DeviceLastUsedByUserName": "Last used by {0}", "HeaderDeleteDevice": "Delete Device", - "DeleteDeviceConfirmation": "Are you sure you with to delete this device? It will reappear the next time a user signs in with it.", + "DeleteDeviceConfirmation": "Are you sure you wish to delete this device? It will reappear the next time a user signs in with it.", "LabelEnableCameraUploadFor": "Enable camera upload for:", "HeaderSelectUploadPath": "Select Upload Path", "LabelEnableCameraUploadForHelp": "Uploads will occur automatically in the background when signed into Media Browser." diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index e576180c47..c104d27388 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -1229,7 +1229,10 @@ "LabelCustomDeviceDisplayName": "Display name:", "LabelCustomDeviceDisplayNameHelp": "Supply a custom display name or leave empty to use the name reported by the device.", "HeaderInviteUser": "Invite User", - "LabelConnectInviteHelp": "This is the username or email used to sign in to the Media Browser website.", + "LabelConnectInviteUserHelp": "This is the username or email that your friend uses to sign in to the Media Browser website.", "HeaderInviteUserHelp": "Sharing your media with friends is easier than ever before with Media Browser Connect.", - "ButtonSendInvitation": "Send Invitation" + "ButtonSendInvitation": "Send Invitation", + "HeaderGuests": "Guests", + "HeaderLocalUsers": "Local Users", + "HeaderPendingInvitations": "Pending Invitations" } diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 2c9319e39e..2c873f9266 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -412,7 +412,7 @@ namespace MediaBrowser.ServerApplication //SyncRepository = await GetSyncRepository().ConfigureAwait(false); //RegisterSingleInstance(SyncRepository); - UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService); + UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager); RegisterSingleInstance(UserManager); LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager);