Esempio n. 1
0
        public IdentityUserManager(IUserStore <User, int> store, IIdentityEmailService emailService, IIdentitySmsService smsService)
            : base(store)
        {
            // Configure validation logic for usernames
            this.UserValidator = new UserValidator <User, int>(this)
            {
                AllowOnlyAlphanumericUserNames = false,
                RequireUniqueEmail             = true
            };

            // Configure validation logic for passwords
            this.PasswordValidator = new PasswordValidator
            {
                RequiredLength          = 6,
                RequireNonLetterOrDigit = false,
                RequireDigit            = false,
                RequireLowercase        = false,
                RequireUppercase        = false,
            };

            // Configure user lockout defaults
            this.UserLockoutEnabledByDefault          = true;
            this.DefaultAccountLockoutTimeSpan        = TimeSpan.FromMinutes(5);
            this.MaxFailedAccessAttemptsBeforeLockout = 5;

            // Register two factor authentication providers. This application uses Phone and Emails as a step of receiving a code for verifying the user
            // You can write your own provider and plug it in here.
            this.RegisterTwoFactorProvider("Phone Code", new PhoneNumberTokenProvider <User, int>
            {
                MessageFormat = "Your security code is {0}"
            });

            this.RegisterTwoFactorProvider("Email Code", new EmailTokenProvider <User, int>
            {
                Subject    = "Security Code",
                BodyFormat = "Your security code is {0}"
            });

            this.EmailService = emailService;
            this.SmsService   = smsService;

            var dataProtectionProvider = Startup.DataProtectionProvider;

            if (dataProtectionProvider != null)
            {
                this.UserTokenProvider =
                    new DataProtectorTokenProvider <User, int>(dataProtectionProvider.Create("ASP.NET Identity"));
            }
        }
Esempio n. 2
0
 public DBDevelopmentData(IIdentityEmailService emailService, IIdentitySmsService smsService)
 {
     this.emailService = emailService;
     this.smsService   = smsService;
 }