Exemple #1
0
        public UserManager(IUserStore <TUser> store, IOptions <AuthOptions> options, IPasswordHasher <TUser> passwordHasher, IEnumerable <IUserValidator <TUser> > userValidators,
                           IEnumerable <IPasswordValidator <TUser> > passwordValidators, AuthErrorDescriber errors, IServiceProvider services, ILogger <UserManager <TUser> > logger)
        {
            if (store == null)
            {
                throw new ArgumentNullException(nameof(store));
            }

            Store          = store;
            Options        = options?.Value ?? new AuthOptions();
            PasswordHasher = passwordHasher;
            ErrorDescriber = errors;
            Logger         = logger;

            if (userValidators != null)
            {
                foreach (var v in userValidators)
                {
                    UserValidators.Add(v);
                }
            }
            if (passwordValidators != null)
            {
                foreach (var v in passwordValidators)
                {
                    PasswordValidators.Add(v);
                }
            }

            _services = services;

            if (Options.Stores.ProtectPersonalData)
            {
                if (!(Store is IProtectedUserStore <TUser>))
                {
                    throw new InvalidOperationException("Store is not a protected user store!");
                }
                if (services.GetService <ILookupProtector>() == null)
                {
                    throw new InvalidOperationException("There's no personal data protector!");
                }
            }
        }