Example #1
0
 public UserService(IUserRepository userRepository, IAuthenticateService authenticateService, ILoginRepository loginRepository, IPasswordHashService passwordHashService)
 {
     _userRepository      = userRepository;
     _authenticateService = authenticateService;
     _loginRepository     = loginRepository;
     _passwordHashService = passwordHashService;
 }
Example #2
0
 public UserService(IOptions <UserConfig> config, ILogger <UserService> logger, IDbOperations <User> userDbOperations, IPasswordHashService passwordHashService)
 {
     _userDbOperations    = userDbOperations;
     _passwordHashService = passwordHashService;
     _userDbOperations.InitializeDb(config.Value.ConnectionString, config.Value.DatabaseName, config.Value.CollectionName);
     _logger = logger;
 }
Example #3
0
 public UserController(IUserService userService, IPasswordHashService passwordHashService, IMapper mapper, IRoleService roleService)
 {
     _userService         = userService;
     _passwordHashService = passwordHashService;
     _mapper      = mapper;
     _roleService = roleService;
 }
Example #4
0
        public User(Guid id, string username, string password, IPasswordHashService hashService)
        {
            if (id == default(Guid))
            {
                throw new ArgumentException($"Invalid user id {id}.", nameof(id));
            }

            if (IsValidUsername(username) == false)
            {
                throw new ArgumentException("The username should be alphanumeric, between 6 and 20 symbols, and it could contain '_' or '-'.");
            }

            if (IsValidPassword(password) == false)
            {
                throw new ArgumentException("The password should be between 8 and 20 symbols and it should contain a number, a captial letter and a special symbol.");
            }

            if (hashService == null)
            {
                throw new ArgumentNullException("Hash service is required.", nameof(hashService));
            }

            Id           = id;
            Username     = username;
            PasswordHash = hashService.GetPasswordHash(password);
        }
 /// <summary>
 /// 构造一个内容门户存储初始化器。
 /// </summary>
 /// <param name="contentOptions">给定的 <see cref="IOptions{ContentBuilderOptions}"/>。</param>
 /// <param name="portalOptions">给定的 <see cref="IOptions{PortalBuilderOptions}"/>。</param>
 /// <param name="passwordHash">给定的 <see cref="IPasswordHashService{TInternalUser}"/>。</param>
 /// <param name="validator">给定的 <see cref="IDataInitializationValidator"/>。</param>
 /// <param name="generator">给定的 <see cref="IStoreIdentificationGenerator"/>。</param>
 /// <param name="loggerFactory">给定的 <see cref="ILoggerFactory"/>。</param>
 public ContentPortalStoreInitializer(IOptions <ContentBuilderOptions> contentOptions,
                                      IOptions <PortalBuilderOptions> portalOptions,
                                      IPasswordHashService <PortalInternalUser <Guid, Guid> > passwordHash,
                                      IDataInitializationValidator validator, IStoreIdentificationGenerator generator, ILoggerFactory loggerFactory)
     : base(contentOptions, portalOptions, passwordHash, validator, generator, loggerFactory)
 {
 }
 public UpdateReaderCommandHandler(IUserRepository userRepository,
                                   IPasswordHashService passwordHashService,
                                   IMapper <User, UserDTO> mapper)
 {
     _userRepository      = userRepository;
     _passwordHashService = passwordHashService;
     _mapper = mapper;
 }
Example #7
0
        public AuthService(IConfiguration configuration, IUnitOfWork unitOfWork, IPasswordHashService passwordHash)
        {
            var jwtOptions = new JwtOptions();

            configuration.GetSection(nameof(JwtOptions)).Bind(jwtOptions);
            _key          = jwtOptions.Secret;
            _unitOfWork   = unitOfWork;
            _passwordHash = passwordHash;
        }
Example #8
0
 public WebsiteCreateOrUpdateHandler(IWebsiteRepositoty websiteRepositoty,
                                     IFileService fileService,
                                     IEntityMapper <WebsiteRequest, Website> mapper,
                                     IPasswordHashService passwordHashService)
 {
     _websiteRepositoty   = websiteRepositoty;
     _fileService         = fileService;
     _mapper              = mapper;
     _passwordHashService = passwordHashService;
 }
 public AccountController(IStore <User> userStore,
                          IStore <Role> roleStore,
                          IStore <Department> departmentStore,
                          IPasswordHashService passwordHash,
                          IUserProfileService userProfile)
 {
     _userStore       = userStore;
     _roleStore       = roleStore;
     _departmentStore = departmentStore;
     _passwordHash    = passwordHash;
     _userProfile     = userProfile;
 }
Example #10
0
        public void ChangePassword(string oldPassword, string newPassword, IPasswordHashService hashService)
        {
            if (IsValidPassword(newPassword) == false)
                throw new ArgumentException("The password should be between 8 and 20 symbols and it should contain a number, a captial letter and a special symbol.");

            if (hashService.GetPasswordHash(oldPassword) == PasswordHash)
            {
                PasswordHash = hashService.GetPasswordHash(newPassword);
            }
            else
                throw new InvalidOperationException("Wrong passoword");
        }
Example #11
0
 public AuthService(AuthSettings authSettings,
                    IPasswordHashService passwordHashService,
                    IProgressLogger progressLogger,
                    IRepository <User, int> userRepository,
                    IRepository <Role, int> rolesRepository,
                    IRepository <UserToRole, int> userToRolesRepository)
 {
     _authSettings          = authSettings;
     _passwordHashService   = passwordHashService;
     _progressLogger        = progressLogger;
     _userRepository        = userRepository;
     _rolesRepository       = rolesRepository;
     _userToRolesRepository = userToRolesRepository;
 }
Example #12
0
 public UsersService(IRepository <User, int> userRepository,
                     IRepository <Role, int> rolesRepository,
                     IRepository <UserToRole, int> userToRolesRepository,
                     IMapper mapper,
                     IPasswordHashService passwordHashService,
                     IProgressLogger progressLogger)
 {
     _userRepository        = userRepository;
     _rolesRepository       = rolesRepository;
     _userToRolesRepository = userToRolesRepository;
     _mapper = mapper;
     _passwordHashService = passwordHashService;
     _progressLogger      = progressLogger;
 }
 public DefaultPasswordService(
     IApplicationLocalizer localizer,
     ILogger <DefaultPasswordService> logger,
     IPasswordHashService passwordHashService,
     IPasswordHashStore passwordHashStore,
     PasswordlessLoginOptions passwordlessLoginOptions
     )
 {
     _localizer                = localizer;
     _logger                   = logger;
     _passwordHashService      = passwordHashService;
     _passwordHashStore        = passwordHashStore;
     _passwordlessLoginOptions = passwordlessLoginOptions;
 }
Example #14
0
        public void ChangePassword(string oldPassword, string newPassword, IPasswordHashService hashService)
        {
            if (IsValidPassword(newPassword) == false)
            {
                throw new ArgumentException("The password should be between 8 and 20 symbols and it should contain a number, a captial letter and a special symbol.");
            }

            if (hashService.GetPasswordHash(oldPassword) == PasswordHash)
            {
                PasswordHash = hashService.GetPasswordHash(newPassword);
            }
            else
            {
                throw new InvalidOperationException("Wrong passoword");
            }
        }
Example #15
0
        public User(Guid id, string username, string password, IPasswordHashService hashService)
        {
            if (id == default(Guid))
                throw new ArgumentException($"Invalid user id {id}.", nameof(id));

            if (IsValidUsername(username) == false)
                throw new ArgumentException("The username should be alphanumeric, between 6 and 20 symbols, and it could contain '_' or '-'.");

            if (IsValidPassword(password) == false)
                throw new ArgumentException("The password should be between 8 and 20 symbols and it should contain a number, a captial letter and a special symbol.");

            if (hashService == null)
                throw new ArgumentNullException("Hash service is required.", nameof(hashService));

            Id = id;
            Username = username;
            PasswordHash = hashService.GetPasswordHash(password);
        }
Example #16
0
 public UserService
 (
     IUserRepositoryService userRepositoryService,
     IPasswordHashService passwordHashService,
     IJsonWebTokenService jwtService,
     IHttpRequestParser httpRequestParser,
     IEmailService emailService,
     ITwoFactorAuthenticatorManager factorAuthenticatorManager,
     IWhitelistedIpRepositoryService whitelistedIpRepositoryService,
     ILoginAttemptsRepositoryService loginAttemptsRepositoryService,
     IRefreshTokenRepositoryService refreshTokenRepositoryService
 )
 {
     _userRepositoryService          = userRepositoryService;
     _passwordHashService            = passwordHashService;
     _jwtService                     = jwtService;
     _httpRequestParser              = httpRequestParser;
     _emailService                   = emailService;
     _factorAuthenticatorManager     = factorAuthenticatorManager;
     _whitelistedIpRepositoryService = whitelistedIpRepositoryService;
     _loginAttemptsRepositoryService = loginAttemptsRepositoryService;
     _refreshTokenRepositoryService  = refreshTokenRepositoryService;
 }
Example #17
0
 public UserService(IUserRepository userRepository, IPasswordHashService passwordHashService)
 {
     this.userRepository = userRepository;
     this.passwordHashService = passwordHashService;
 }