Remove UserManager.AddParts

pull/3366/head
Patrick Barron 5 years ago
parent f8e8626898
commit 3b085f6a03

@ -547,6 +547,9 @@ namespace Emby.Server.Implementations
serviceCollection.AddSingleton(ServerConfigurationManager); serviceCollection.AddSingleton(ServerConfigurationManager);
serviceCollection.AddSingleton<Func<IReadOnlyCollection<IPasswordResetProvider>>>(() => GetExports<IPasswordResetProvider>());
serviceCollection.AddSingleton<Func<IReadOnlyCollection<IAuthenticationProvider>>>(() => GetExports<IAuthenticationProvider>());
serviceCollection.AddSingleton<ILocalizationManager, LocalizationManager>(); serviceCollection.AddSingleton<ILocalizationManager, LocalizationManager>();
serviceCollection.AddSingleton<IBlurayExaminer, BdInfoExaminer>(); serviceCollection.AddSingleton<IBlurayExaminer, BdInfoExaminer>();
@ -795,7 +798,6 @@ namespace Emby.Server.Implementations
Resolve<IMediaSourceManager>().AddParts(GetExports<IMediaSourceProvider>()); Resolve<IMediaSourceManager>().AddParts(GetExports<IMediaSourceProvider>());
Resolve<INotificationManager>().AddParts(GetExports<INotificationService>(), GetExports<INotificationTypeFactory>()); Resolve<INotificationManager>().AddParts(GetExports<INotificationService>(), GetExports<INotificationTypeFactory>());
Resolve<IUserManager>().AddParts(GetExports<IAuthenticationProvider>(), GetExports<IPasswordResetProvider>());
Resolve<IIsoManager>().AddParts(GetExports<IIsoMounter>()); Resolve<IIsoManager>().AddParts(GetExports<IIsoMounter>());
} }

@ -39,12 +39,11 @@ namespace Jellyfin.Server.Implementations.Users
private readonly IApplicationHost _appHost; private readonly IApplicationHost _appHost;
private readonly IImageProcessor _imageProcessor; private readonly IImageProcessor _imageProcessor;
private readonly ILogger<UserManager> _logger; private readonly ILogger<UserManager> _logger;
private readonly IReadOnlyCollection<IPasswordResetProvider> _passwordResetProviders;
private IAuthenticationProvider[] _authenticationProviders = null!; private readonly IReadOnlyCollection<IAuthenticationProvider> _authenticationProviders;
private DefaultAuthenticationProvider _defaultAuthenticationProvider = null!; private readonly InvalidAuthProvider _invalidAuthProvider;
private InvalidAuthProvider _invalidAuthProvider = null!; private readonly DefaultAuthenticationProvider _defaultAuthenticationProvider;
private IPasswordResetProvider[] _passwordResetProviders = null!; private readonly DefaultPasswordResetProvider _defaultPasswordResetProvider;
private DefaultPasswordResetProvider _defaultPasswordResetProvider = null!;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="UserManager"/> class. /// 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="appHost">The application host.</param>
/// <param name="imageProcessor">The image processor.</param> /// <param name="imageProcessor">The image processor.</param>
/// <param name="logger">The logger.</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( public UserManager(
JellyfinDbProvider dbProvider, JellyfinDbProvider dbProvider,
ICryptoProvider cryptoProvider, ICryptoProvider cryptoProvider,
INetworkManager networkManager, INetworkManager networkManager,
IApplicationHost appHost, IApplicationHost appHost,
IImageProcessor imageProcessor, IImageProcessor imageProcessor,
ILogger<UserManager> logger) ILogger<UserManager> logger,
Func<IReadOnlyCollection<IPasswordResetProvider>> passwordResetProviders,
Func<IReadOnlyCollection<IAuthenticationProvider>> authenticationProviders)
{ {
_dbProvider = dbProvider; _dbProvider = dbProvider;
_cryptoProvider = cryptoProvider; _cryptoProvider = cryptoProvider;
@ -69,6 +72,13 @@ namespace Jellyfin.Server.Implementations.Users
_appHost = appHost; _appHost = appHost;
_imageProcessor = imageProcessor; _imageProcessor = imageProcessor;
_logger = logger; _logger = logger;
_passwordResetProviders = passwordResetProviders.Invoke();
_authenticationProviders = authenticationProviders.Invoke();
_invalidAuthProvider = _authenticationProviders.OfType<InvalidAuthProvider>().First();
_defaultAuthenticationProvider = _authenticationProviders.OfType<DefaultAuthenticationProvider>().First();
_defaultPasswordResetProvider = _passwordResetProviders.OfType<DefaultPasswordResetProvider>().First();
} }
/// <inheritdoc/> /// <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 /> /// <inheritdoc />
public void Initialize() public void Initialize()
{ {

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Jellyfin.Data.Entities; using Jellyfin.Data.Entities;
using MediaBrowser.Controller.Authentication;
using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Events; using MediaBrowser.Model.Events;
@ -166,8 +165,6 @@ namespace MediaBrowser.Controller.Library
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
Task<PinRedeemResult> RedeemPasswordResetPin(string pin); Task<PinRedeemResult> RedeemPasswordResetPin(string pin);
void AddParts(IEnumerable<IAuthenticationProvider> authenticationProviders, IEnumerable<IPasswordResetProvider> passwordResetProviders);
NameIdPair[] GetAuthenticationProviders(); NameIdPair[] GetAuthenticationProviders();
NameIdPair[] GetPasswordResetProviders(); NameIdPair[] GetPasswordResetProviders();

Loading…
Cancel
Save