Ejemplo n.º 1
0
        public static DogUserManager Create(IdentityFactoryOptions <DogUserManager> options,
                                            IOwinContext context)
        {
            var manager = new DogUserManager(new UserStore <User>(context.Get <DogCodingContext>()));

            manager.UserValidator = new UserValidator <User>(manager)
            {
                AllowOnlyAlphanumericUserNames = false,
                RequireUniqueEmail             = true
            };

            manager.PasswordValidator = new PasswordValidator
            {
                RequiredLength          = 6,
                RequireNonLetterOrDigit = true,
                RequireDigit            = true,
                RequireLowercase        = true,
                RequireUppercase        = true,
            };

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

            manager.RegisterTwoFactorProvider("PhoneCode", new PhoneNumberTokenProvider <User>
            {
                MessageFormat = "Your security code is: {0}"
            });
            manager.RegisterTwoFactorProvider("EmailCode", new EmailTokenProvider <User>
            {
                Subject    = "SecurityCode",
                BodyFormat = "Your security code is {0}"
            });
            manager.EmailService = new EmailService();
            manager.SmsService   = new SmsService();
            var dataProtectionProvider = options.DataProtectionProvider;

            if (dataProtectionProvider != null)
            {
                manager.UserTokenProvider =
                    new DataProtectorTokenProvider <User>(dataProtectionProvider.Create("ASP.NET Identity to DogCoding"));
            }
            return(manager);
        }
Ejemplo n.º 2
0
 public ApplicationSignInManager(DogUserManager userManager, IAuthenticationManager authenticationManager) :
     base(userManager, authenticationManager)
 {
 }