|
|
@ -259,6 +259,11 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
|
|
{
|
|
|
|
{
|
|
|
|
user.LastActivityDate = user.LastLoginDate = DateTime.UtcNow;
|
|
|
|
user.LastActivityDate = user.LastLoginDate = DateTime.UtcNow;
|
|
|
|
await UpdateUser(user).ConfigureAwait(false);
|
|
|
|
await UpdateUser(user).ConfigureAwait(false);
|
|
|
|
|
|
|
|
await UpdateInvalidLoginAttemptCount(user, 0).ConfigureAwait(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await UpdateInvalidLoginAttemptCount(user, user.Policy.InvalidLoginAttemptCount + 1).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_logger.Info("Authentication request for {0} {1}.", user.Name, (success ? "has succeeded" : "has been denied"));
|
|
|
|
_logger.Info("Authentication request for {0} {1}.", user.Name, (success ? "has succeeded" : "has been denied"));
|
|
|
@ -266,6 +271,22 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
|
|
return success;
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async Task UpdateInvalidLoginAttemptCount(User user, int newValue)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (user.Policy.InvalidLoginAttemptCount != newValue || newValue > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
user.Policy.InvalidLoginAttemptCount = newValue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (newValue >= 3)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.Debug("Disabling user {0} due to {1} unsuccessful login attempts.", user.Name, newValue.ToString(CultureInfo.InvariantCulture));
|
|
|
|
|
|
|
|
user.Policy.IsDisabled = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await UpdateUserPolicy(user, user.Policy, false).ConfigureAwait(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string GetPasswordHash(User user)
|
|
|
|
private string GetPasswordHash(User user)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return string.IsNullOrEmpty(user.Password)
|
|
|
|
return string.IsNullOrEmpty(user.Password)
|
|
|
@ -332,11 +353,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!user.Configuration.HasMigratedToPolicy)
|
|
|
|
if (!user.Configuration.HasMigratedToPolicy)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
user.Policy.BlockUnratedItems = user.Configuration.BlockUnratedItems;
|
|
|
|
|
|
|
|
user.Policy.EnableContentDeletion = user.Configuration.EnableContentDeletion;
|
|
|
|
|
|
|
|
user.Policy.EnableLiveTvAccess = user.Configuration.EnableLiveTvAccess;
|
|
|
|
|
|
|
|
user.Policy.EnableLiveTvManagement = user.Configuration.EnableLiveTvManagement;
|
|
|
|
|
|
|
|
user.Policy.EnableMediaPlayback = user.Configuration.EnableMediaPlayback;
|
|
|
|
|
|
|
|
user.Policy.IsAdministrator = user.Configuration.IsAdministrator;
|
|
|
|
user.Policy.IsAdministrator = user.Configuration.IsAdministrator;
|
|
|
|
|
|
|
|
|
|
|
|
await UpdateUserPolicy(user, user.Policy, false);
|
|
|
|
await UpdateUserPolicy(user, user.Policy, false);
|
|
|
@ -915,10 +931,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
user.Configuration.IsAdministrator = user.Policy.IsAdministrator;
|
|
|
|
user.Configuration.IsAdministrator = user.Policy.IsAdministrator;
|
|
|
|
user.Configuration.EnableLiveTvManagement = user.Policy.EnableLiveTvManagement;
|
|
|
|
|
|
|
|
user.Configuration.EnableLiveTvAccess = user.Policy.EnableLiveTvAccess;
|
|
|
|
|
|
|
|
user.Configuration.EnableMediaPlayback = user.Policy.EnableMediaPlayback;
|
|
|
|
|
|
|
|
user.Configuration.EnableContentDeletion = user.Policy.EnableContentDeletion;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await UpdateConfiguration(user, user.Configuration, true).ConfigureAwait(false);
|
|
|
|
await UpdateConfiguration(user, user.Configuration, true).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|