/// <summary> /// Initializes a new instance of the <see cref="UserFactory" /> class. /// </summary> /// <param name="statusChecker">The status checker.</param> /// <param name="passwordValidator">The password validator.</param> /// <param name="symmetricKeyStore">The symmetric key store.</param> /// <param name="entityContextFactory">The entity context factory.</param> public UserFactory(IMembershipStatusChecker statusChecker, IPasswordValidator passwordValidator, ISymmetricKeyStore symmetricKeyStore, IEntityContextFactory entityContextFactory) { _statusChecker = statusChecker; _passwordValidator = passwordValidator; _symmetricKeyStore = symmetricKeyStore; _entityContextFactory = entityContextFactory; }
public LoginAuthenticationService(ILoginAuthenticationRepository repository, IPasswordValidator passwordValidator, ISaltedHashGenerator saltedHashGenerator) { if (repository == null) throw new ArgumentNullException(nameof(repository)); if (passwordValidator == null) throw new ArgumentNullException(nameof(passwordValidator)); if (saltedHashGenerator == null) throw new ArgumentNullException(nameof(saltedHashGenerator)); _repository = repository; _passwordValidator = passwordValidator; _saltedHashGenerator = saltedHashGenerator; }
public UserService(IUserRepository userRepository, IPasswordHelperService passwordHelperService, IPasswordValidator passwordValidator, IValidator validator, MembershipSettingsBag settings) { _userRepository = userRepository; _passwordHelperService = passwordHelperService; _passwordValidator = passwordValidator; _validator = validator; _settings = settings; }
/// <summary> /// 初始化一个<see cref="OsharpAuthorizationServerProvider"/>类型的新实例 /// </summary> public OsharpAuthorizationServerProvider(IServiceProvider serviceProvider) { serviceProvider.CheckNotNull("serviceProvider"); _clientValidator = serviceProvider.GetService<IClientValidator>(); if (_clientValidator == null) { throw new InvalidOperationException(Resources.ClientValidatorIsNull); } _passwordValidator = serviceProvider.GetService<IPasswordValidator>(); if (_passwordValidator == null) { throw new InvalidOperationException(Resources.PasswordValidatorIsNull); } }
public PasswordService(IPasswordHelperService passwordHelper, IPasswordValidator passwordValidator, IUserRepository userRepository, IValidator validator, IEmailService emailService, EmailSettings emailSettings, MembershipSettingsBag settings) { _passwordHelper = passwordHelper; _passwordValidator = passwordValidator; _userRepository = userRepository; _validator = validator; _emailService = emailService; _emailSettings = emailSettings; _settings = settings; }
public ForgotPasswordController( IApplicationUserManager userManager, IPasswordValidator <User> passwordValidator, IEmailSender emailSender, IOptionsSnapshot <SiteSettings> siteOptions) { _userManager = userManager; _userManager.CheckArgumentIsNull(nameof(_userManager)); _passwordValidator = passwordValidator; _passwordValidator.CheckArgumentIsNull(nameof(_passwordValidator)); _emailSender = emailSender; _emailSender.CheckArgumentIsNull(nameof(_emailSender)); _siteOptions = siteOptions; _siteOptions.CheckArgumentIsNull(nameof(_siteOptions)); }
public UsersController(UserManager <ApplicationUser> userManager, BTCPayServerOptions btcPayServerOptions, RoleManager <IdentityRole> roleManager, SettingsRepository settingsRepository, EventAggregator eventAggregator, IPasswordValidator <ApplicationUser> passwordValidator, RateLimitService throttleService, BTCPayServerOptions options, IAuthorizationService authorizationService) { _userManager = userManager; _btcPayServerOptions = btcPayServerOptions; _roleManager = roleManager; _settingsRepository = settingsRepository; _eventAggregator = eventAggregator; _passwordValidator = passwordValidator; _throttleService = throttleService; _options = options; _authorizationService = authorizationService; }
public void SetUp() { // Usermanager mocks var userStoreMock = Substitute.For <IUserStore <User> >(); var optionsMock = Substitute.For <IOptions <IdentityOptions> >(); var passwordHasherMock = Substitute.For <IPasswordHasher <User> >(); var userValidatorMock = Substitute.For <IEnumerable <IUserValidator <User> > >(); var passwordValidatorMock = Substitute.For <IEnumerable <IPasswordValidator <User> > >(); var lookUpNormalizerMock = Substitute.For <ILookupNormalizer>(); var identityErrorDescriberMock = Substitute.For <IdentityErrorDescriber>(); var serviceProviderMock = Substitute.For <IServiceProvider>(); var loggerMock = Substitute.For <ILogger <UserManager <User> > >(); _userManager = Substitute.For <UserManager <User> >( userStoreMock, optionsMock, passwordHasherMock, userValidatorMock, passwordValidatorMock, lookUpNormalizerMock, identityErrorDescriberMock, serviceProviderMock, loggerMock); //SignInManager mocks var contextAccessorMock = Substitute.For <IHttpContextAccessor>(); var claimsPricipleFactoryMock = Substitute.For <IUserClaimsPrincipalFactory <User> >(); var loggerMockSM = Substitute.For <ILogger <SignInManager <User> > >(); var schemaProvider = Substitute.For <IAuthenticationSchemeProvider>(); var userConfirmation = Substitute.For <IUserConfirmation <User> >(); _signInManager = Substitute.For <SignInManager <User> >( _userManager, contextAccessorMock, claimsPricipleFactoryMock, optionsMock, loggerMockSM, schemaProvider, userConfirmation); _userValidator = Substitute.For <IUserValidator <User> >(); _passwordValidator = Substitute.For <IPasswordValidator <User> >(); _passwordHasher = Substitute.For <IPasswordHasher <User> >(); }
public CreatePasswordCommandValidator(IConfirmationService confirmation, IPasswordValidator validator) { RuleFor(x => x) .CustomAsync(async(command, context, ct) => { var data = await confirmation.GetAsync(command.ConfirmationId, ct); if (data is null) { context.AddFailure( new ValidationFailure(nameof(CreatePasswordCommand.ConfirmationCode), "Not found") { ErrorCode = ElwarkExceptionCodes.ConfirmationNotFound }); return; } if (data.Code != command.ConfirmationCode) { context.AddFailure( new ValidationFailure(nameof(CreatePasswordCommand.ConfirmationCode), "Not match") { ErrorCode = ElwarkExceptionCodes.ConfirmationNotMatch }); } }); RuleFor(x => x.Password) .NotEmpty() .CustomAsync(async(password, context, token) => { var(isSuccess, error) = await validator.ValidateAsync(password, token); if (!isSuccess) { context.AddFailure( new ValidationFailure(nameof(SignUpByEmailCommand.Password), "Incorrect password") { ErrorCode = error } ); } }); }
public bool VerifyPassword_CurrentValidation_ResultOfValidation(string password) { var repository = new SqlRepository(); var v1 = new ContainsDigitPasswordValidator(); var v2 = new ContainsCharPasswordValidator(); var v3 = new MaxLengthPasswordValidator(15); var v4 = new MinLengthPasswordValidator(8); var validators = new IPasswordValidator[] { new ContainsDigitPasswordValidator(), new ContainsCharPasswordValidator(), new MaxLengthPasswordValidator(15), new MinLengthPasswordValidator(8) }; var validator = new CompositionOfPasswordValidators(validators); var checker = new PasswordCheckerService(repository, new [] { validator }); return(checker.VerifyPassword(password).Item1); }
public AccountController( UserManager <AppUser> userManager, IUserValidator <AppUser> userValidator, IPasswordValidator <AppUser> passwordValidator, IPasswordHasher <AppUser> passwordHasher, SignInManager <AppUser> signInManager, IUserProfileRepository profileRepository, IAdvertRepository advertRepository, IFlashMessage flashMessage) { this.userManager = userManager; this.userValidator = userValidator; this.passwordValidator = passwordValidator; this.passwordHasher = passwordHasher; this.signInManager = signInManager; this.profileRepository = profileRepository; this.advertRepository = advertRepository; this.flashMessage = flashMessage; }
public TenantsController( ICoreUnitOfWork uow, UserManager <User> userManager, IPasswordValidator <User> passwordValidator, IWorkContext workContext, IPasswordHasher <User> passwordHasher, //IConnectionMultiplexer redis, IDistributedCache cache, IModuleManager moduleManager) { _uow = uow; _userManager = userManager; _passwordValidator = passwordValidator; _workContext = workContext; _passwordHasher = passwordHasher; //_redis = redis; _cache = cache; _moduleManager = moduleManager; }
public async Task <IActionResult> ChangePassword(ChangePasswordViewModel model) { if (ModelState.IsValid) { User user = await _userManager.FindByIdAsync(model.Id); if (user != null) { IPasswordValidator <User> passwordValidator = HttpContext.RequestServices.GetService(typeof(IPasswordValidator <User>)) as IPasswordValidator <User>; IPasswordHasher <User> passwordHasher = HttpContext.RequestServices.GetService(typeof(IPasswordHasher <User>)) as IPasswordHasher <User>; if (passwordValidator != null) { IdentityResult result = await passwordValidator.ValidateAsync(_userManager, user, model.NewPassword); if (result.Succeeded) { if (passwordHasher != null) { user.PasswordHash = passwordHasher.HashPassword(user, model.NewPassword); } await _userManager.UpdateAsync(user); return(RedirectToAction("Index", "Account")); } foreach (IdentityError error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } } else { ModelState.AddModelError(string.Empty, "User not found."); } } return(View(model)); }
public AccountController(IAuthProvider authProvider, IPasswordValidator passwordValidator, IPasswordEncrypter passwordEncryptor, IUsersRepository userRepository, IMobileNumbersRepository mobileNumberRepository, IProfilesRepository profilesRepository, IOrdersRepository ordersRepository, IRolesRepository rolesRepository ) { _authProvider = authProvider; _passwordValidator = passwordValidator; _passwordEncryptor = passwordEncryptor; _userRepository = userRepository; _mobileNumbersRepository = mobileNumberRepository; _profilesRepository = profilesRepository; _ordersRepository = ordersRepository; _rolesRepository = rolesRepository; }
public UserController( UserManager <UserModel> userManager, ICubeCollectionService cubeCollections, ICubeService cubeService, IConfiguration configuration, ICategoryService categoryService, ISeriesService seriesService, IPasswordValidator <UserModel> passwordValidator, IPasswordHasher <UserModel> passwordHasher) { _userManager = userManager; _cubeCollectionsService = cubeCollections; _cubeService = cubeService; _configuration = configuration; _categoryService = categoryService; _seriesService = seriesService; _passwordValidator = passwordValidator; _passwordHasher = passwordHasher; }
public AdminCredentialsCreateRequestValidator(IPasswordValidator passwordValidator) { CascadeMode = CascadeMode.StopOnFirstFailure; RuleFor(o => o.AdminId) .NotEmpty() .WithMessage("Admin id required."); RuleFor(o => o.Login) .NotEmpty() .WithMessage("Email required.") .EmailAddress() .WithMessage("Email invalid."); RuleFor(o => o.Password) .NotEmpty() .WithMessage("Password required") .Must(passwordValidator.IsValidPassword) .WithMessage(passwordValidator.BuildValidationMessage()); }
public RegisterController(IEmailSender emailSender, IMemoryCache cache, ILogger <RegisterController> logger, IApplicationUserManager userManager, IPasswordValidator <User> passwordValidator, IUserValidator <User> userValidator, IEventBus eventBus, IdentitySettings settings, IUnitOfWork context) { _emailSender = emailSender ?? throw new ArgumentNullException(nameof(emailSender)); _cache = cache ?? throw new ArgumentNullException(nameof(cache)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _userManager = userManager ?? throw new ArgumentNullException(nameof(userManager)); _passwordValidator = passwordValidator ?? throw new ArgumentNullException(nameof(passwordValidator)); _userValidator = userValidator ?? throw new ArgumentNullException(nameof(userValidator)); this._eventBus = eventBus; this._settings = settings; _context = context ?? throw new ArgumentNullException(nameof(context)); }
public ResetPasswordRequestValidator(IPasswordValidator passwordValidator) { RuleFor(x => x.CustomerEmail) .NotEmpty() .WithMessage("The Email field is required.") .EmailAddress() .WithMessage("A valid email address is required."); RuleFor(x => x.ResetIdentifier) .NotEmpty() .WithMessage("Reset identifier is required"); RuleFor(x => x.Password) .NotNull() .WithMessage("Password is a required field") .NotEmpty() .WithMessage("Password is a required field"); RuleFor(x => x.Password) .Must(passwordValidator.IsValidPassword) .When(x => !string.IsNullOrEmpty(x.Password)) .WithMessage(passwordValidator.BuildValidationMessage()); }
public AccountController( ILogger <AccountController> logger , IOptions <ApplicationSettings> appsettings , UserManager <Usuario> userManager , SignInManager <Usuario> signInManager , RoleManager <Perfil> roleManager , IPasswordHasher <Usuario> passwordHasher , IPasswordValidator <Usuario> passwordValidator , IUsuarioSenhaHistoryService usuarioSenhaHistoryService ) : base(logger) { _logger = logger; _appSettings = appsettings.Value; _userManager = userManager; _signInManager = signInManager; _roleManager = roleManager; _passwordHasher = passwordHasher; _passwordValidator = passwordValidator; _usuarioSenhaHistoryService = usuarioSenhaHistoryService; }
public AdminPasswordResetRequestValidator(IPasswordValidator passwordValidator) { CascadeMode = CascadeMode.StopOnFirstFailure; RuleFor(o => o.ResetIdentifier) .NotEmpty() .WithMessage("Reset identifier required."); RuleFor(o => o.Login) .NotEmpty() .WithMessage("Email required.") .EmailAddress() .WithMessage("Email invalid."); RuleFor(o => o.Password) .NotEmpty() .WithMessage("Password required.") .Must(passwordValidator.IsValidPassword) .WithMessage(passwordValidator.BuildValidationMessage()); }
private void TryDataProcess(string data, IPasswordValidator validator) { notifier.DisplayStep(counter++, data); try { if (validator.IsValidPassword(data)) { isPasswordFound = true; successPassword = data; cancel.Cancel(); } } catch (Exception e) { Console.WriteLine(e); isPasswordFound = true; successPassword = null; cancel.Cancel(); } }
public AccountController( UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, IConfiguration configuration, IPasswordHasher <ApplicationUser> passwordHasher, IPasswordValidator <ApplicationUser> passwordValidator, IMapper mapper, ICompanyRepository companyRepository, IDavaRepository davaRepository, RoleManager <IdentityRole> roleManager ) { _userManager = userManager; _singInManager = signInManager; _configuration = configuration; _passwordHasher = passwordHasher; _passwordValidator = passwordValidator; _mapper = mapper; _companyRepository = companyRepository; _davaRepository = davaRepository; _roleManager = roleManager; }
//ICharacterRace characterrace; public void ResolveInterfaces(IContainer container) { //----------------Ninject--------- //loginvalidator = kernel.Get<ILoginValidator>(); //passwordvalidator = kernel.Get<IPasswordValidator>(); //characterskillpoints = kernel.Get<ICharacterSkillPoints>(); // characterrace = kernel.Get<ICharacterRace>(); //----------------StructureMap--------- //using (var nested = container.GetNestedContainer()) //{ // loginvalidator = nested.GetInstance<ILoginValidator>(); // passwordvalidator = nested.GetInstance<IPasswordValidator>(); // characterskillpoints = nested.GetInstance<ICharacterSkillPoints>(); // //characterrace = nested.GetInstance<ICharacterRace>(); //} //----------------Castle Windsor-------- - //loginvalidator = container.Resolve<ILoginValidator>(); //passwordvalidator = container.Resolve<IPasswordValidator>(); //characterskillpoints = container.Resolve<ICharacterSkillPoints>(); //characterrace = container.Resolve<ICharacterRace>(); //----------------Unity--------- //loginvalidator = container.Resolve<ILoginValidator>(); //passwordvalidator = container.Resolve<IPasswordValidator>(); //characterskillpoints = container.Resolve<ICharacterSkillPoints>(); //characterrace = container.Resolve<ICharacterRace>(); //----------------Autofac--------- using (var scope = container.BeginLifetimeScope()) { loginvalidator = scope.Resolve <ILoginValidator>(); passwordvalidator = scope.Resolve <IPasswordValidator>(); characterskillpoints = scope.Resolve <ICharacterSkillPoints>(); } }
public UpdatePasswordCommandValidator(IPasswordValidator validator) { RuleFor(x => x.OldPassword) .NotEmpty(); RuleFor(x => x.NewPassword) .NotEmpty() .CustomAsync(async(password, context, token) => { var(isSuccess, error) = await validator.ValidateAsync(password, token); if (!isSuccess) { context.AddFailure( new ValidationFailure(nameof(SignUpByEmailCommand.Password), "Incorrect password") { ErrorCode = error } ); } }); }
public NewCharacterConnectionContext(IServiceProvider services, IConnection connection) : base(services, connection) { _characterNameValidator = services.GetService <ICharacterNameValidator>(); _passwordValidator = services.GetService <IPasswordValidator>(); _actions[0] = CharacterName; _prompts[0] = ContentKeys.CreateCharacterName; _actions[1] = Password; _prompts[1] = ContentKeys.CreateCharacterPassword; _actions[2] = PasswordConfirm; _prompts[2] = ContentKeys.CreateCharacterPasswordConfirm; _actions[3] = Email; _prompts[3] = ContentKeys.CreateCharacterEmail; _actions[4] = RealNameQuestion; _prompts[4] = ContentKeys.CreateCharacterRealNameQuestion; }
public AccountController( ApplicationDbContext dbContext, UserManager <AppUser> userManager, SignInManager <AppUser> signInManager, IUserValidator <AppUser> userValidator, IPasswordValidator <AppUser> passwordValidator, IPasswordHasher <AppUser> passwordHasher, IEmailService emailService, IConfiguration configuration, IHostingEnvironment env) { _dbContext = dbContext; _userManager = userManager; _signInManager = signInManager; _userValidator = userValidator; _passwordValidator = passwordValidator; _passwordHasher = passwordHasher; _emailService = emailService; _configuration = configuration; _env = env; }
public EFUnitOfWorkAsync(ApplicationDbContext cont, IUserValidator <ApplicationUser> userValid, IPasswordValidator <ApplicationUser> passValid, IPasswordHasher <ApplicationUser> passwordHash, ApplicationUserManager userManager, SignInManager <ApplicationUser> signInManager, RoleManager <IdentityRole> roleManager) { _context = cont; CharityMakers = new EFRepositoryAsync <CharityMaker>(cont); Donations = new EFRepositoryAsync <Donation>(cont); Orphanages = new OrphanageRepositoryAsync(cont); Orphans = new EFRepositoryAsync <Orphan>(cont); Representatives = new EFRepositoryAsync <Representative>(cont); Volunteers = new EFRepositoryAsync <Volunteer>(cont); PasswordHasher = passwordHash; UserValidator = userValid; PasswordValidator = passValid; PhoneValidator = new FamilyNetPhoneValidator(); UserManager = userManager; SignInManager = signInManager; RoleManager = roleManager; BaseItemTypes = new EFRepositoryAsync <BaseItemType>(cont); TypeBaseItems = new TypeBaseItemRepository(cont); // TODO : rewrite this }
public CommonController(UserManager <AppUser> userMgr , ICommonServices commonservices , IUserServices userservices , AppIdentityDbContext db , IUserValidator <AppUser> userValid , IPasswordValidator <AppUser> passValid , IPasswordHasher <AppUser> passwordHash , IHostingEnvironment hostingEnvironment ) { userManager = userMgr; _commonservices = commonservices; _userservices = userservices; _db = db; userValidator = userValid; passwordValidator = passValid; passwordHasher = passwordHash; _hostingEnvironment = hostingEnvironment; }
public CardManagerService( EgidDbContext context, UserManager <Card> userManager, RoleManager <IdentityRole> roleManager, SignInManager <Card> signInManager, IPasswordValidator <Card> passwordValidator, IDateTime dateTime, ICurrentUserService currentUser, IHashService hashService, IJwtTokenService jwtTokenService, IFilesDirectoryService directoryService) { _context = context; _userManager = userManager; _signInManager = signInManager; _passwordValidator = passwordValidator; _dateTime = dateTime; _currentUser = currentUser; _hashService = hashService; _jwtTokenService = jwtTokenService; _directoryService = directoryService; _roleManager = roleManager; }
public PartnerCredentialsUpdateRequestValidator(IPasswordValidator passwordValidator) { CascadeMode = CascadeMode.StopOnFirstFailure; RuleFor(o => o.ClientId) .NotNull() .NotEmpty() .WithMessage("Client id required."); RuleFor(o => o.ClientSecret) .NotNull() .NotEmpty() .WithMessage("Password required") .Must(passwordValidator.IsValidPassword) .WithMessage(passwordValidator.BuildValidationMessage()); RuleFor(o => o.PartnerId) .NotNull() .NotEmpty() .WithMessage("Partner id required."); }
public CustomersController( ICustomerService customerService, ICustomerManagementServiceClient customerManagementServiceClient, IRequestContext requestContext, IMapper mapper, IPasswordValidator passwordValidator, ILogFactory logFactory, ISessionsServiceClient sessionsServiceClient, ICustomerProfileClient customerProfileClient, ICredentialsClient credentialsClient) { _customerService = customerService; _customerManagementServiceClient = customerManagementServiceClient; _requestContext = requestContext; _mapper = mapper; _passwordValidator = passwordValidator; _sessionsServiceClient = sessionsServiceClient; _customerProfileClient = customerProfileClient; _credentialsClient = credentialsClient; _log = logFactory.CreateLog(this); }
public AdminController( IProductRepository productRepository, ICategoryRepository categoryRepository, RoleManager <IdentityRole> roleManager, UserManager <AppUser> userManager, IOrderRepository orderRepository, IUserRolesRepository userRolesRepository, IOrderPositionRepository orderPositionRepository, IPasswordValidator <AppUser> passwordValidator, IPasswordHasher <AppUser> passwordHasher) { this.productRepository = productRepository; this.categoryRepository = categoryRepository; this.roleManager = roleManager; this.userManager = userManager; this.orderRepository = orderRepository; this.userRolesRepository = userRolesRepository; this.orderPositionRepository = orderPositionRepository; this.passwordValidator = passwordValidator; this.passwordHasher = passwordHasher; }
public AdminController(UserManager <User> usrMgr, IUserValidator <User> userValid, IPasswordValidator <User> passValid, IPasswordHasher <User> passwordHash, IMessageRepository repos, IProjectRepository proj, IProductRepository prod, IProjectProductsRepository prop, INoteRepository nor, ISettingRepository set) { userManager = usrMgr; userValidator = userValid; passwordValidator = passValid; passwordHasher = passwordHash; message = repos; project = proj; product = prod; prodProj = prop; note = nor; settings = set; }
public UpdateRequestCredentialsValidator(IPasswordValidator passwordValidator) { RuleFor(x => x.Login) .NotEmpty() .WithMessage("Email address is required.") .EmailAddress() .WithMessage("A valid email address is required."); RuleFor(x => x.CustomerId) .NotNull() .WithMessage("CustomerId is required.") .NotEmpty() .WithMessage("CustomerId cannot be empty."); RuleFor(x => x.Password) .NotNull() .WithMessage("Password is a required field") .NotEmpty() .WithMessage("Password is a required field"); RuleFor(x => x.Password) .Must(passwordValidator.IsValidPassword) .When(x => !string.IsNullOrEmpty(x.Password)) .WithMessage(passwordValidator.BuildValidationMessage()); }
public static async Task <IdentityResult> CustomValidateAsync(this IPasswordValidator <VesizleUser> validator, UserManager <VesizleUser> userManager, VesizleUser user, string password) { var identityResult = await validator.ValidateAsync(userManager, user, password); List <IdentityError> errors = identityResult.Succeeded ? new List <IdentityError>() : identityResult.Errors.ToList(); if (password.ToLower().Contains(user.UserName.ToLower())) { errors.Add(new IdentityError { Description = "Password cannot contain username" }); } if (password.Contains("123")) { errors.Add(new IdentityError { Description = "Password cannot contain 123 numeric sequence" }); } return(errors.Count == 0 ? IdentityResult.Success : IdentityResult.Failed(errors.ToArray())); }
public ExampleAuthenticationService(IAuthenticationDatabase authenticationDatabase, IPasswordValidator passwordValidator) { this.authenticationDatabase = authenticationDatabase; this.passwordValidator = passwordValidator; }