예제 #1
0
        public static ManaUserManager Create(IdentityFactoryOptions <ManaUserManager> options,
                                             IOwinContext context)
        {
            var userStore    = (IManaUserStore)DependencyResolver.Current.GetService(typeof(IManaUserStore));
            var lockoutStore =
                (IManaUserLockoutStore)DependencyResolver.Current.GetService(typeof(IManaUserLockoutStore));
            var store   = new ManaAuthUserStore(userStore, lockoutStore);
            var manager = new ManaUserManager(store);

            // Configure validation logic for usernames
            manager.UserValidator = new UserValidator <ManaAuthUser, int>(manager)
            {
                AllowOnlyAlphanumericUserNames = false,
                RequireUniqueEmail             = true
            };

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

            // Configure user lockout defaults
            manager.UserLockoutEnabledByDefault          = true;
            manager.DefaultAccountLockoutTimeSpan        = Startup.AuthLockout;
            manager.MaxFailedAccessAttemptsBeforeLockout = 5;

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

            var dataProtectionProvider = options.DataProtectionProvider;

            if (dataProtectionProvider != null)
            {
                manager.UserTokenProvider =
                    new DataProtectorTokenProvider <ManaAuthUser, int>(
                        dataProtectionProvider.Create("ASP.NET Evoto Management Identity"));
            }
            return(manager);
        }
예제 #2
0
 public ManaSignInManager(ManaUserManager userManager, IAuthenticationManager authenticationManager)
     : base(userManager, authenticationManager)
 {
 }