コード例 #1
0
 public ApplicationUserManager(
     IApplicationUserStore store,
     IOptions <IdentityOptions> optionsAccessor,
     IPasswordHasher <User> passwordHasher,
     IEnumerable <IUserValidator <User> > userValidators,
     IEnumerable <IPasswordValidator <User> > passwordValidators,
     ILookupNormalizer keyNormalizer,
     IdentityErrorDescriber errors,
     IServiceProvider services,
     ILogger <ApplicationUserManager> logger,
     IHttpContextAccessor contextAccessor,
     IUnitOfWork uow,
     IUsedPasswordsService usedPasswordsService)
     : base(
         (UserStore <User, Role, ApplicationDbContext, int, UserClaim, UserRole, UserLogin, UserToken, RoleClaim>)store,
         optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger)
 {
     _userStore          = store ?? throw new ArgumentNullException(nameof(_userStore));
     _optionsAccessor    = optionsAccessor ?? throw new ArgumentNullException(nameof(_optionsAccessor));
     _passwordHasher     = passwordHasher ?? throw new ArgumentNullException(nameof(_passwordHasher));
     _userValidators     = userValidators ?? throw new ArgumentNullException(nameof(_userValidators));
     _passwordValidators = passwordValidators ?? throw new ArgumentNullException(nameof(_passwordValidators));
     _keyNormalizer      = keyNormalizer ?? throw new ArgumentNullException(nameof(_keyNormalizer));
     _errors             = errors ?? throw new ArgumentNullException(nameof(_errors));
     _services           = services ?? throw new ArgumentNullException(nameof(_services));
     _logger             = logger ?? throw new ArgumentNullException(nameof(_logger));
     _contextAccessor    = contextAccessor ?? throw new ArgumentNullException(nameof(_contextAccessor));
     _uow = uow ?? throw new ArgumentNullException(nameof(_uow));
     _usedPasswordsService = usedPasswordsService ?? throw new ArgumentNullException(nameof(_usedPasswordsService));
     _users = uow.Set <User>();
     _roles = uow.Set <Role>();
 }
コード例 #2
0
        public ChangePasswordController(
            IApplicationUserManager userManager,
            IApplicationSignInManager signInManager,
            IEmailSender emailSender,
            IPasswordValidator <User> passwordValidator,
            IUsedPasswordsService usedPasswordsService,
            IOptionsSnapshot <SiteSettings> siteOptions)
        {
            _userManager = userManager;
            _userManager.CheckArgumentIsNull(nameof(_userManager));

            _signInManager = signInManager;
            _signInManager.CheckArgumentIsNull(nameof(_signInManager));

            _passwordValidator = passwordValidator;
            _passwordValidator.CheckArgumentIsNull(nameof(_passwordValidator));

            _usedPasswordsService = usedPasswordsService;
            _usedPasswordsService.CheckArgumentIsNull(nameof(_usedPasswordsService));

            _emailSender = emailSender;
            _emailSender.CheckArgumentIsNull(nameof(_emailSender));

            _siteOptions = siteOptions;
            _siteOptions.CheckArgumentIsNull(nameof(_siteOptions));
        }
コード例 #3
0
        public AppUserManager(
            IUsedPasswordsService usedPasswordsService,
            IUserStore <AppUser> store,
            IOptions <IdentityOptions> optionsAccessor,
            IPasswordHasher <AppUser> passwordHasher,
            IEnumerable <IUserValidator <AppUser> > userValidators,
            IEnumerable <IPasswordValidator <AppUser> > passwordValidators,
            ILookupNormalizer keyNormalizer,
            IdentityErrorDescriber errors,
            IServiceProvider services,
            ILogger <UserManager <AppUser> > logger) :

            base(store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger)
        {
            this.usedPasswordsService = usedPasswordsService;
            this.store              = store;
            this.optionsAccessor    = optionsAccessor;
            this.passwordHasher     = passwordHasher;
            this.userValidators     = userValidators;
            this.passwordValidators = passwordValidators;
            this.keyNormalizer      = keyNormalizer;
            this.errors             = errors;
            this.services           = services;
            this.logger             = logger;
        }
コード例 #4
0
        public ApplicationUserManager(
            IApplicationUserStore store,
            IOptions <IdentityOptions> optionsAccessor,
            IPasswordHasher <User> passwordHasher,
            IEnumerable <IUserValidator <User> > userValidators,
            IEnumerable <IPasswordValidator <User> > passwordValidators,
            ILookupNormalizer keyNormalizer,
            IdentityErrorDescriber errors,
            IServiceProvider services,
            ILogger <ApplicationUserManager> logger,
            IHttpContextAccessor contextAccessor,
            IUnitOfWork uow,
            IUsedPasswordsService usedPasswordsService)
            : base((UserStore <User, Role, ApplicationDbContext, int, UserClaim, UserRole, UserLogin, UserToken, RoleClaim>)store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger)
        {
            //  _userStore = store;
            store.CheckArgumentIsNull(nameof(store));

            //  _optionsAccessor = optionsAccessor;
            optionsAccessor.CheckArgumentIsNull(nameof(optionsAccessor));

            // _passwordHasher = passwordHasher;
            passwordHasher.CheckArgumentIsNull(nameof(passwordHasher));

            //  _userValidators = userValidators;
            userValidators.CheckArgumentIsNull(nameof(userValidators));

            // _passwordValidators = passwordValidators;
            passwordValidators.CheckArgumentIsNull(nameof(passwordValidators));

            //_keyNormalizer = keyNormalizer;
            keyNormalizer.CheckArgumentIsNull(nameof(keyNormalizer));

            //_errors = errors;
            errors.CheckArgumentIsNull(nameof(errors));

            // _services = services;
            services.CheckArgumentIsNull(nameof(services));

            //_logger = logger;
            logger.CheckArgumentIsNull(nameof(logger));

            _contextAccessor = contextAccessor;
            _contextAccessor.CheckArgumentIsNull(nameof(_contextAccessor));

            // _uow = uow;
            uow.CheckArgumentIsNull(nameof(uow));

            _usedPasswordsService = usedPasswordsService;
            _usedPasswordsService.CheckArgumentIsNull(nameof(_usedPasswordsService));

            _users = uow.Set <User>();
            _roles = uow.Set <Role>();
        }
コード例 #5
0
 public ChangePasswordController(
     IApplicationUserManager userManager,
     IApplicationSignInManager signInManager,
     IEmailSender emailSender,
     IPasswordValidator <User> passwordValidator,
     IUsedPasswordsService usedPasswordsService,
     IOptionsSnapshot <SiteSettings> siteOptions)
 {
     _userManager          = userManager ?? throw new ArgumentNullException(nameof(_userManager));
     _signInManager        = signInManager ?? throw new ArgumentNullException(nameof(_signInManager));
     _passwordValidator    = passwordValidator ?? throw new ArgumentNullException(nameof(_passwordValidator));
     _usedPasswordsService = usedPasswordsService ?? throw new ArgumentNullException(nameof(_usedPasswordsService));
     _emailSender          = emailSender ?? throw new ArgumentNullException(nameof(_emailSender));
     _siteOptions          = siteOptions ?? throw new ArgumentNullException(nameof(_siteOptions));
 }
コード例 #6
0
        public CustomPasswordValidator(
            IdentityErrorDescriber errors,// How to use CustomIdentityErrorDescriber
            IOptionsSnapshot <SiteSettings> configurationRoot,
            IUsedPasswordsService usedPasswordsService) : base(errors)
        {
            _usedPasswordsService = usedPasswordsService;
            _usedPasswordsService.CheckArgumentIsNull(nameof(_usedPasswordsService));

            configurationRoot.CheckArgumentIsNull(nameof(configurationRoot));
            _passwordsBanList = new HashSet <string>(configurationRoot.Value.PasswordsBanList, StringComparer.OrdinalIgnoreCase);

            if (!_passwordsBanList.Any())
            {
                throw new InvalidOperationException("Please fill the passwords ban list in the appsettings.json file.");
            }
        }
コード例 #7
0
        public CustomPasswordValidator(
            IdentityErrorDescriber errors,// How to use CustomIdentityErrorDescriber
            IdentitySettings configurationRoot,
            IUsedPasswordsService usedPasswordsService) : base(errors)
        {
            _usedPasswordsService = usedPasswordsService ?? throw new ArgumentNullException(nameof(_usedPasswordsService));
            if (configurationRoot == null)
            {
                throw new ArgumentNullException(nameof(configurationRoot));
            }

            _passwordsBanList = new HashSet <string>(configurationRoot.PasswordsBanList, StringComparer.OrdinalIgnoreCase);

            if (!_passwordsBanList.Any())
            {
                throw new InvalidOperationException("Please fill the passwords ban list in the appsettings.json file.");
            }
        }
コード例 #8
0
        public UserProfileController(
            IApplicationUserManager userManager,
            IApplicationRoleManager roleManager,
            IApplicationSignInManager signInManager,
            IProtectionProviderService protectionProviderService,
            IUserValidator <User> userValidator,
            IUsedPasswordsService usedPasswordsService,
            IUsersPhotoService usersPhotoService,
            IOptionsSnapshot <SiteSettings> siteOptions,
            IEmailSender emailSender,
            ILogger <UserProfileController> logger)
        {
            _userManager = userManager;
            _userManager.CheckArgumentIsNull(nameof(_userManager));

            _roleManager = roleManager;
            _roleManager.CheckArgumentIsNull(nameof(_roleManager));

            _signInManager = signInManager;
            _signInManager.CheckArgumentIsNull(nameof(_signInManager));

            _protectionProviderService = protectionProviderService;
            _protectionProviderService.CheckArgumentIsNull(nameof(_protectionProviderService));

            _userValidator = userValidator;
            _userValidator.CheckArgumentIsNull(nameof(_userValidator));

            _usedPasswordsService = usedPasswordsService;
            _usedPasswordsService.CheckArgumentIsNull(nameof(_usedPasswordsService));

            _usersPhotoService = usersPhotoService;
            _usersPhotoService.CheckArgumentIsNull(nameof(_usersPhotoService));

            _siteOptions = siteOptions;
            _siteOptions.CheckArgumentIsNull(nameof(_siteOptions));

            _emailSender = emailSender;
            _emailSender.CheckArgumentIsNull(nameof(_emailSender));

            _logger = logger;
            _logger.CheckArgumentIsNull(nameof(_logger));
        }
コード例 #9
0
 public ApplicationUserManager(IUserStore <AppUser> store,
                               IOptions <IdentityOptions> optionsAccessor,
                               IPasswordHasher <AppUser> passwordHasher,
                               IEnumerable <IUserValidator <AppUser> > userValidators,
                               IEnumerable <IPasswordValidator <AppUser> > passwordValidators,
                               ILookupNormalizer keyNormalizer,
                               IdentityErrorDescriber errors,
                               IServiceProvider services,
                               ILogger <UserManager <AppUser> > logger,
                               IHttpContextAccessor contextAccessor,
                               IUsedPasswordsService usedPasswordsService,
                               ApplicationDbContext context)
     : base(store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger)
 {
     _contextAccessor      = contextAccessor;
     _usedPasswordsService = usedPasswordsService;
     _context = context;
     _users   = context.Set <AppUser>();
     _roles   = context.Set <Role>();
 }
コード例 #10
0
 public UserProfileController(
     IApplicationUserManager userManager,
     IApplicationRoleManager roleManager,
     IApplicationSignInManager signInManager,
     IProtectionProviderService protectionProviderService,
     IUserValidator <User> userValidator,
     IUsedPasswordsService usedPasswordsService,
     IUsersPhotoService usersPhotoService,
     IOptionsSnapshot <SiteSettings> siteOptions,
     IEmailSender emailSender,
     ILogger <UserProfileController> logger)
 {
     _userManager               = userManager ?? throw new ArgumentNullException(nameof(userManager));
     _roleManager               = roleManager ?? throw new ArgumentNullException(nameof(roleManager));
     _signInManager             = signInManager ?? throw new ArgumentNullException(nameof(signInManager));
     _protectionProviderService = protectionProviderService ?? throw new ArgumentNullException(nameof(protectionProviderService));
     _userValidator             = userValidator ?? throw new ArgumentNullException(nameof(userValidator));
     _usedPasswordsService      = usedPasswordsService ?? throw new ArgumentNullException(nameof(usedPasswordsService));
     _usersPhotoService         = usersPhotoService ?? throw new ArgumentNullException(nameof(usersPhotoService));
     _siteOptions               = siteOptions ?? throw new ArgumentNullException(nameof(siteOptions));
     _emailSender               = emailSender ?? throw new ArgumentNullException(nameof(emailSender));
     _logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }
コード例 #11
0
 public CheckLastNPasswordsValidator(IUsedPasswordsService usedPasswordsService, IOptionsSnapshot <SiteSettings> configuration)
 {
     this.usedPasswordsService = usedPasswordsService;
     this.configuration        = configuration;
     passwordsBanList          = new HashSet <string>(configuration.Value.PasswordsBanList);
 }