Ver Fonte

Fix bugs relating to users not being properly locked out.

Patrick Barron há 5 anos atrás
pai
commit
e3f9aaa9c6

+ 4 - 14
Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs

@@ -104,8 +104,10 @@ namespace Emby.Server.Implementations.Activity
                         _localization.GetLocalizedString("UserLockedOutWithName"),
                         _localization.GetLocalizedString("UserLockedOutWithName"),
                         e.Argument.Username),
                         e.Argument.Username),
                     NotificationType.UserLockedOut.ToString(),
                     NotificationType.UserLockedOut.ToString(),
-                    e.Argument.Id))
-                .ConfigureAwait(false);
+                    e.Argument.Id)
+            {
+                LogSeverity = LogLevel.Error
+            }).ConfigureAwait(false);
         }
         }
 
 
         private async void OnSubtitleDownloadFailure(object sender, SubtitleDownloadFailureEventArgs e)
         private async void OnSubtitleDownloadFailure(object sender, SubtitleDownloadFailureEventArgs e)
@@ -303,18 +305,6 @@ namespace Emby.Server.Implementations.Activity
             }).ConfigureAwait(false);
             }).ConfigureAwait(false);
         }
         }
 
 
-        private async void OnUserPolicyUpdated(object sender, GenericEventArgs<User> e)
-        {
-            await CreateLogEntry(new ActivityLog(
-                string.Format(
-                    CultureInfo.InvariantCulture,
-                    _localization.GetLocalizedString("UserPolicyUpdatedWithName"),
-                    e.Argument.Username),
-                "UserPolicyUpdated",
-                e.Argument.Id))
-                .ConfigureAwait(false);
-        }
-
         private async void OnUserDeleted(object sender, GenericEventArgs<User> e)
         private async void OnUserDeleted(object sender, GenericEventArgs<User> e)
         {
         {
             await CreateLogEntry(new ActivityLog(
             await CreateLogEntry(new ActivityLog(

+ 4 - 3
Jellyfin.Server.Implementations/Users/UserManager.cs

@@ -4,6 +4,7 @@ using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Globalization;
 using System.Globalization;
 using System.Linq;
 using System.Linq;
+using System.Runtime.InteropServices.ComTypes;
 using System.Text;
 using System.Text;
 using System.Text.RegularExpressions;
 using System.Text.RegularExpressions;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
@@ -800,16 +801,16 @@ namespace Jellyfin.Server.Implementations.Users
 
 
         private void IncrementInvalidLoginAttemptCount(User user)
         private void IncrementInvalidLoginAttemptCount(User user)
         {
         {
-            int invalidLogins = user.InvalidLoginAttemptCount;
+            user.InvalidLoginAttemptCount++;
             int? maxInvalidLogins = user.LoginAttemptsBeforeLockout;
             int? maxInvalidLogins = user.LoginAttemptsBeforeLockout;
-            if (maxInvalidLogins.HasValue && invalidLogins >= maxInvalidLogins)
+            if (maxInvalidLogins.HasValue && user.InvalidLoginAttemptCount >= maxInvalidLogins)
             {
             {
                 user.SetPermission(PermissionKind.IsDisabled, true);
                 user.SetPermission(PermissionKind.IsDisabled, true);
                 OnUserLockedOut?.Invoke(this, new GenericEventArgs<User>(user));
                 OnUserLockedOut?.Invoke(this, new GenericEventArgs<User>(user));
                 _logger.LogWarning(
                 _logger.LogWarning(
                     "Disabling user {Username} due to {Attempts} unsuccessful login attempts.",
                     "Disabling user {Username} due to {Attempts} unsuccessful login attempts.",
                     user.Username,
                     user.Username,
-                    invalidLogins);
+                    user.InvalidLoginAttemptCount);
             }
             }
 
 
             UpdateUser(user);
             UpdateUser(user);