The Free Software Media System - Server Backend & API
Remove UserManager.AddParts
Patrick Barron3b085f6a03bf
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.csindex f6077400d6..908fe4b302 100644--- a/Emby.Server.Implementations/ApplicationHost.cs+++ b/Emby.Server.Implementations/ApplicationHost.cs@@ -547,6 +547,9 @@ namespace Emby.Server.ImplementationsserviceCollection.AddSingleton(ServerConfigurationManager);+ serviceCollection.AddSingleton<Func<IReadOnlyCollection<IPasswordResetProvider>>>(() => GetExports<IPasswordResetProvider>());+ serviceCollection.AddSingleton<Func<IReadOnlyCollection<IAuthenticationProvider>>>(() => GetExports<IAuthenticationProvider>());+serviceCollection.AddSingleton<ILocalizationManager, LocalizationManager>();serviceCollection.AddSingleton<IBlurayExaminer, BdInfoExaminer>();@@ -795,7 +798,6 @@ namespace Emby.Server.ImplementationsResolve<IMediaSourceManager>().AddParts(GetExports<IMediaSourceProvider>());Resolve<INotificationManager>().AddParts(GetExports<INotificationService>(), GetExports<INotificationTypeFactory>());- Resolve<IUserManager>().AddParts(GetExports<IAuthenticationProvider>(), GetExports<IPasswordResetProvider>());Resolve<IIsoManager>().AddParts(GetExports<IIsoMounter>());}diff --git a/Jellyfin.Server.Implementations/Users/UserManager.cs b/Jellyfin.Server.Implementations/Users/UserManager.csindex 6283a1bca5..d4b91f3c53 100644--- a/Jellyfin.Server.Implementations/Users/UserManager.cs+++ b/Jellyfin.Server.Implementations/Users/UserManager.cs@@ -39,12 +39,11 @@ namespace Jellyfin.Server.Implementations.Usersprivate readonly IApplicationHost _appHost;private readonly IImageProcessor _imageProcessor;private readonly ILogger<UserManager> _logger;-- private IAuthenticationProvider[] _authenticationProviders = null!;- private DefaultAuthenticationProvider _defaultAuthenticationProvider = null!;- private InvalidAuthProvider _invalidAuthProvider = null!;- private IPasswordResetProvider[] _passwordResetProviders = null!;- private DefaultPasswordResetProvider _defaultPasswordResetProvider = null!;+ private readonly IReadOnlyCollection<IPasswordResetProvider> _passwordResetProviders;+ private readonly IReadOnlyCollection<IAuthenticationProvider> _authenticationProviders;+ private readonly InvalidAuthProvider _invalidAuthProvider;+ private readonly DefaultAuthenticationProvider _defaultAuthenticationProvider;+ private readonly DefaultPasswordResetProvider _defaultPasswordResetProvider;/// <summary>/// Initializes a new instance of the <see cref="UserManager"/> class.@@ -55,13 +54,17 @@ namespace Jellyfin.Server.Implementations.Users/// <param name="appHost">The application host.</param>/// <param name="imageProcessor">The image processor.</param>/// <param name="logger">The logger.</param>+ /// <param name="passwordResetProviders">A function that returns available password reset providers.</param>+ /// <param name="authenticationProviders">A function that returns available authentication providers.</param>public UserManager(JellyfinDbProvider dbProvider,ICryptoProvider cryptoProvider,INetworkManager networkManager,IApplicationHost appHost,IImageProcessor imageProcessor,- ILogger<UserManager> logger)+ ILogger<UserManager> logger,+ Func<IReadOnlyCollection<IPasswordResetProvider>> passwordResetProviders,+ Func<IReadOnlyCollection<IAuthenticationProvider>> authenticationProviders){_dbProvider = dbProvider;_cryptoProvider = cryptoProvider;@@ -69,6 +72,13 @@ namespace Jellyfin.Server.Implementations.Users_appHost = appHost;_imageProcessor = imageProcessor;_logger = logger;++ _passwordResetProviders = passwordResetProviders.Invoke();+ _authenticationProviders = authenticationProviders.Invoke();++ _invalidAuthProvider = _authenticationProviders.OfType<InvalidAuthProvider>().First();+ _defaultAuthenticationProvider = _authenticationProviders.OfType<DefaultAuthenticationProvider>().First();+ _defaultPasswordResetProvider = _passwordResetProviders.OfType<DefaultPasswordResetProvider>().First();}/// <inheritdoc/>@@ -557,17 +567,6 @@ namespace Jellyfin.Server.Implementations.Users};}- /// <inheritdoc/>- public void AddParts(IEnumerable<IAuthenticationProvider> authenticationProviders, IEnumerable<IPasswordResetProvider> passwordResetProviders)- {- _authenticationProviders = authenticationProviders.ToArray();- _passwordResetProviders = passwordResetProviders.ToArray();-- _invalidAuthProvider = _authenticationProviders.OfType<InvalidAuthProvider>().First();- _defaultAuthenticationProvider = _authenticationProviders.OfType<DefaultAuthenticationProvider>().First();- _defaultPasswordResetProvider = _passwordResetProviders.OfType<DefaultPasswordResetProvider>().First();- }-/// <inheritdoc />public void Initialize(){diff --git a/MediaBrowser.Controller/Library/IUserManager.cs b/MediaBrowser.Controller/Library/IUserManager.csindex e73fe71205..88b96ddbf8 100644--- a/MediaBrowser.Controller/Library/IUserManager.cs+++ b/MediaBrowser.Controller/Library/IUserManager.cs@@ -2,7 +2,6 @@ using System;using System.Collections.Generic;using System.Threading.Tasks;using Jellyfin.Data.Entities;-using MediaBrowser.Controller.Authentication;using MediaBrowser.Model.Configuration;using MediaBrowser.Model.Dto;using MediaBrowser.Model.Events;@@ -166,8 +165,6 @@ namespace MediaBrowser.Controller.Library/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>Task<PinRedeemResult> RedeemPasswordResetPin(string pin);- void AddParts(IEnumerable<IAuthenticationProvider> authenticationProviders, IEnumerable<IPasswordResetProvider> passwordResetProviders);-NameIdPair[] GetAuthenticationProviders();NameIdPair[] GetPasswordResetProviders();