public static void FromLegacy(
            this MembershipRebootConfiguration config,
            INotificationService notificationService,
            IPasswordPolicy passwordPolicy)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (notificationService != null)
            {
                config.AddEventHandler(new NotificationServiceEventHandler(notificationService));
                if (config.SecuritySettings.RequireAccountVerification)
                {
                    config.AddEventHandler(new NotificationServiceAccountCreatedEventHandler(notificationService));
                }
            }

            if (passwordPolicy != null)
            {
                config.RegisterPasswordValidator(new DelegateValidator(
                                                     (svc, acct, password) =>
                {
                    if (!passwordPolicy.ValidatePassword(password))
                    {
                        return(new ValidationResult("Invalid password: " + passwordPolicy.PolicyMessage));
                    }
                    return(null);
                }));
            }
        }
コード例 #2
0
 public static void RegisterPasswordValidator <TAccount>(this MembershipRebootConfiguration <TAccount> config, Func <UserAccountService <TAccount>, TAccount, string, ValidationResult> func)
     where TAccount : UserAccount
 {
     if (config == null)
     {
         throw new ArgumentNullException("config");
     }
     config.RegisterPasswordValidator(new DelegateValidator <TAccount>(func));
 }
コード例 #3
0
 public static void ConfigurePasswordComplexity <TAccount>(this MembershipRebootConfiguration <TAccount> config, int minimumLength, int minimumNumberOfComplexityRules)
     where TAccount : UserAccount
 {
     if (config == null)
     {
         throw new ArgumentNullException("config");
     }
     config.RegisterPasswordValidator(new PasswordComplexityValidator <TAccount>(minimumLength, minimumNumberOfComplexityRules));
 }
        public static void ConfigurePasswordComplexity(this MembershipRebootConfiguration config)

        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            config.RegisterPasswordValidator(new PasswordComplexityValidator <UserAccount>());
        }