Merge pull request #2400 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2017-01-16 01:28:14 -05:00 committed by GitHub
commit 890d9c60dc
6 changed files with 105 additions and 59 deletions

View File

@ -1122,7 +1122,7 @@ namespace Emby.Server.Implementations.Connect
}
}
public async Task Authenticate(string username, string passwordMd5)
public async Task<ConnectAuthenticationResult> Authenticate(string username, string passwordMd5)
{
if (string.IsNullOrWhiteSpace(username))
{
@ -1151,6 +1151,7 @@ namespace Emby.Server.Implementations.Connect
// No need to examine the response
using (var response = (await _httpClient.SendAsync(options, "POST").ConfigureAwait(false)).Content)
{
return _json.DeserializeFromStream<ConnectAuthenticationResult>(response);
}
}

View File

@ -1512,7 +1512,8 @@ namespace Emby.Server.Implementations.Dto
return artist;
}
}
return item.GetParent();
return item.DisplayParent ?? item.GetParent();
}
private void AddInheritedImages(BaseItemDto dto, BaseItem item, DtoOptions options, BaseItem owner)

View File

@ -142,7 +142,8 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
}
}
}
else
{
var fullName = fileSystemInfo.FullName;
if (libraryManager.IsAudioFile(fullName, libraryOptions))
@ -150,6 +151,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
return true;
}
}
}
if (notMultiDisc)
{

View File

@ -236,18 +236,10 @@ namespace Emby.Server.Implementations.Library
var user = Users
.FirstOrDefault(i => string.Equals(username, i.Name, StringComparison.OrdinalIgnoreCase));
if (user == null)
{
throw new SecurityException("Invalid username or password entered.");
}
if (user.Policy.IsDisabled)
{
throw new SecurityException(string.Format("The {0} account is currently disabled. Please consult with your administrator.", user.Name));
}
var success = false;
if (user != null)
{
// Authenticate using local credentials if not a guest
if (!user.ConnectLinkType.HasValue || user.ConnectLinkType.Value != UserLinkType.Guest)
{
@ -259,6 +251,48 @@ namespace Emby.Server.Implementations.Library
}
}
// Maybe user accidently entered connect credentials. let's be flexible
if (!success && user.ConnectLinkType.HasValue && !string.IsNullOrWhiteSpace(passwordMd5) && !string.IsNullOrWhiteSpace(user.ConnectUserName))
{
try
{
await _connectFactory().Authenticate(user.ConnectUserName, passwordMd5).ConfigureAwait(false);
success = true;
}
catch
{
}
}
}
// Try originally entered username
if (!success && (user == null || !string.Equals(user.ConnectUserName, username, StringComparison.OrdinalIgnoreCase)))
{
try
{
var connectAuthResult = await _connectFactory().Authenticate(username, passwordMd5).ConfigureAwait(false);
user = Users.FirstOrDefault(i => string.Equals(i.ConnectUserId, connectAuthResult.User.Id, StringComparison.OrdinalIgnoreCase));
success = user != null;
}
catch
{
}
}
if (user == null)
{
throw new SecurityException("Invalid username or password entered.");
}
if (user.Policy.IsDisabled)
{
throw new SecurityException(string.Format("The {0} account is currently disabled. Please consult with your administrator.", user.Name));
}
// Update LastActivityDate and LastLoginDate, then save
if (success)
{

View File

@ -61,7 +61,7 @@ namespace MediaBrowser.Controller.Connect
/// <param name="username">The username.</param>
/// <param name="passwordMd5">The password MD5.</param>
/// <returns>Task.</returns>
Task Authenticate(string username, string passwordMd5);
Task<ConnectAuthenticationResult> Authenticate(string username, string passwordMd5);
/// <summary>
/// Gets the local user.

View File

@ -135,6 +135,8 @@ namespace Mono.Nat.Pmp
private async void CreatePortMapListen(UdpClient udpClient, Mapping mapping, CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
{
try
{
var result = await udpClient.ReceiveAsync().ConfigureAwait(false);
var endPoint = result.RemoteEndPoint;
@ -187,6 +189,12 @@ namespace Mono.Nat.Pmp
mapping.Expiration = DateTime.Now.AddSeconds(lifetime);
return;
}
catch (Exception ex)
{
NatUtility.Logger.ErrorException("Error in CreatePortMapListen", ex);
return;
}
}
}
/// <summary>