public virtual async Task RemoveTokenValidityKeyAsync(
     TUser user,
     string tokenValidityKey,
     CancellationToken cancellationToken = default(CancellationToken))
 {
     await MajidUserStore.RemoveTokenValidityKeyAsync(user, tokenValidityKey, cancellationToken);
 }
 public virtual async Task <bool> IsTokenValidityKeyValidAsync(
     TUser user,
     string tokenValidityKey,
     CancellationToken cancellationToken = default(CancellationToken))
 {
     return(await MajidUserStore.IsTokenValidityKeyValidAsync(user, tokenValidityKey, cancellationToken));
 }
 public virtual async Task AddTokenValidityKeyAsync(
     TUser user,
     string tokenValidityKey,
     DateTime expireDate,
     CancellationToken cancellationToken = default(CancellationToken))
 {
     await MajidUserStore.AddTokenValidityKeyAsync(user, tokenValidityKey, expireDate, cancellationToken);
 }
        public MajidUserManager(
            MajidRoleManager <TRole, TUser> roleManager,
            MajidUserStore <TRole, TUser> userStore,
            IOptions <IdentityOptions> optionsAccessor,
            IPasswordHasher <TUser> passwordHasher,
            IEnumerable <IUserValidator <TUser> > userValidators,
            IEnumerable <IPasswordValidator <TUser> > passwordValidators,
            ILookupNormalizer keyNormalizer,
            IdentityErrorDescriber errors,
            IServiceProvider services,
            ILogger <UserManager <TUser> > logger,
            IPermissionManager permissionManager,
            IUnitOfWorkManager unitOfWorkManager,
            ICacheManager cacheManager,
            IRepository <OrganizationUnit, long> organizationUnitRepository,
            IRepository <UserOrganizationUnit, long> userOrganizationUnitRepository,
            IOrganizationUnitSettings organizationUnitSettings,
            ISettingManager settingManager)
            : base(
                userStore,
                optionsAccessor,
                passwordHasher,
                userValidators,
                passwordValidators,
                keyNormalizer,
                errors,
                services,
                logger)
        {
            _permissionManager              = permissionManager;
            _unitOfWorkManager              = unitOfWorkManager;
            _cacheManager                   = cacheManager;
            _organizationUnitRepository     = organizationUnitRepository;
            _userOrganizationUnitRepository = userOrganizationUnitRepository;
            _organizationUnitSettings       = organizationUnitSettings;
            _settingManager                 = settingManager;
            _optionsAccessor                = optionsAccessor;

            MajidUserStore         = userStore;
            RoleManager            = roleManager;
            LocalizationManager    = NullLocalizationManager.Instance;
            LocalizationSourceName = MajidZeroConsts.LocalizationSourceName;
        }
示例#5
0
        protected MajidUserManager(
            MajidUserStore <TRole, TUser> userStore,
            MajidRoleManager <TRole, TUser> roleManager,
            IPermissionManager permissionManager,
            IUnitOfWorkManager unitOfWorkManager,
            ICacheManager cacheManager,
            IRepository <OrganizationUnit, long> organizationUnitRepository,
            IRepository <UserOrganizationUnit, long> userOrganizationUnitRepository,
            IOrganizationUnitSettings organizationUnitSettings,
            ILocalizationManager localizationManager,
            IdentityEmailMessageService emailService,
            ISettingManager settingManager,
            IUserTokenProviderAccessor userTokenProviderAccessor)
            : base(userStore)
        {
            MajidStore             = userStore;
            RoleManager            = roleManager;
            LocalizationManager    = localizationManager;
            LocalizationSourceName = MajidZeroConsts.LocalizationSourceName;
            _settingManager        = settingManager;

            _permissionManager              = permissionManager;
            _unitOfWorkManager              = unitOfWorkManager;
            _cacheManager                   = cacheManager;
            _organizationUnitRepository     = organizationUnitRepository;
            _userOrganizationUnitRepository = userOrganizationUnitRepository;
            _organizationUnitSettings       = organizationUnitSettings;

            MajidSession = NullMajidSession.Instance;

            UserLockoutEnabledByDefault          = true;
            DefaultAccountLockoutTimeSpan        = TimeSpan.FromMinutes(5);
            MaxFailedAccessAttemptsBeforeLockout = 5;

            EmailService = emailService;

            UserTokenProvider = userTokenProviderAccessor.GetUserTokenProviderOrNull <TUser>();
        }
        public virtual async Task <IdentityResult> ChangePasswordAsync(TUser user, string newPassword)
        {
            var errors = new List <IdentityError>();

            foreach (var validator in PasswordValidators)
            {
                var validationResult = await validator.ValidateAsync(this, user, newPassword);

                if (!validationResult.Succeeded)
                {
                    errors.AddRange(validationResult.Errors);
                }
            }

            if (errors.Any())
            {
                return(IdentityResult.Failed(errors.ToArray()));
            }

            await MajidUserStore.SetPasswordHashAsync(user, PasswordHasher.HashPassword(user, newPassword));

            return(IdentityResult.Success);
        }
 protected virtual Task <string> GetOldUserNameAsync(long userId)
 {
     return(MajidUserStore.GetUserNameFromDatabaseAsync(userId));
 }
 public virtual Task <TUser> FindByNameOrEmailAsync(int?tenantId, string userNameOrEmailAddress)
 {
     return(MajidUserStore.FindByNameOrEmailAsync(tenantId, userNameOrEmailAddress));
 }
 public virtual Task <TUser> FindAsync(int?tenantId, UserLoginInfo login)
 {
     return(MajidUserStore.FindAsync(tenantId, login));
 }
 public virtual Task <List <TUser> > FindAllAsync(UserLoginInfo login)
 {
     return(MajidUserStore.FindAllAsync(login));
 }
 public virtual Task <TUser> FindByNameOrEmailAsync(string userNameOrEmailAddress)
 {
     return(MajidUserStore.FindByNameOrEmailAsync(userNameOrEmailAddress));
 }