Exemple #1
0
        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();
        }
        public UserManager(
            JellyfinDbProvider dbProvider,
            ICryptoProvider cryptoProvider,
            INetworkManager networkManager,
            IApplicationHost appHost,
            IImageProcessor imageProcessor,
            ILogger <UserManager> logger)
        {
            _dbProvider     = dbProvider;
            _cryptoProvider = cryptoProvider;
            _networkManager = networkManager;
            _appHost        = appHost;
            _imageProcessor = imageProcessor;
            _logger         = logger;

            _passwordResetProviders  = appHost.GetExports <IPasswordResetProvider>();
            _authenticationProviders = appHost.GetExports <IAuthenticationProvider>();

            _invalidAuthProvider           = _authenticationProviders.OfType <InvalidAuthProvider>().First();
            _defaultAuthenticationProvider = _authenticationProviders.OfType <DefaultAuthenticationProvider>().First();
            _defaultPasswordResetProvider  = _passwordResetProviders.OfType <DefaultPasswordResetProvider>().First();
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UserManager"/> class.
        /// </summary>
        /// <param name="dbProvider">The database provider.</param>
        /// <param name="eventManager">The event manager.</param>
        /// <param name="cryptoProvider">The cryptography provider.</param>
        /// <param name="networkManager">The network manager.</param>
        /// <param name="appHost">The application host.</param>
        /// <param name="imageProcessor">The image processor.</param>
        /// <param name="logger">The logger.</param>
        public UserManager(
            JellyfinDbProvider dbProvider,
            IEventManager eventManager,
            ICryptoProvider cryptoProvider,
            INetworkManager networkManager,
            IApplicationHost appHost,
            IImageProcessor imageProcessor,
            ILogger <UserManager> logger)
        {
            _dbProvider     = dbProvider;
            _eventManager   = eventManager;
            _cryptoProvider = cryptoProvider;
            _networkManager = networkManager;
            _appHost        = appHost;
            _imageProcessor = imageProcessor;
            _logger         = logger;

            _passwordResetProviders  = appHost.GetExports <IPasswordResetProvider>();
            _authenticationProviders = appHost.GetExports <IAuthenticationProvider>();

            _invalidAuthProvider           = _authenticationProviders.OfType <InvalidAuthProvider>().First();
            _defaultAuthenticationProvider = _authenticationProviders.OfType <DefaultAuthenticationProvider>().First();
            _defaultPasswordResetProvider  = _passwordResetProviders.OfType <DefaultPasswordResetProvider>().First();

            _users = new ConcurrentDictionary <Guid, User>();
            using var dbContext = _dbProvider.CreateContext();
            foreach (var user in dbContext.Users
                     .Include(user => user.Permissions)
                     .Include(user => user.Preferences)
                     .Include(user => user.AccessSchedules)
                     .Include(user => user.ProfileImage)
                     .AsEnumerable())
            {
                _users.Add(user.Id, user);
            }
        }