Exemple #1
0
        public static MyIdentityUserManager Create(IdentityFactoryOptions <MyIdentityUserManager> options, IOwinContext context)
        {
            var manager = new MyIdentityUserManager(new UserStore <MyIdentityUser>(context.Get <SecurityDbContext>()));

            // Configurer la logique de validation pour les noms d'utilisateur
            manager.UserValidator = new UserValidator <MyIdentityUser>(manager)
            {
                AllowOnlyAlphanumericUserNames = false,
                RequireUniqueEmail             = true
            };

            // Configurer la logique de validation pour les mots de passe
            manager.PasswordValidator = new PasswordValidator
            {
                RequiredLength          = 6,
                RequireNonLetterOrDigit = true,
                RequireDigit            = true,
                RequireLowercase        = true,
                RequireUppercase        = true,
            };

            // Configurer les valeurs par défaut du verrouillage de l'utilisateur
            manager.UserLockoutEnabledByDefault          = true;
            manager.DefaultAccountLockoutTimeSpan        = TimeSpan.FromMinutes(5);
            manager.MaxFailedAccessAttemptsBeforeLockout = 5;

            var dataProtectionProvider = options.DataProtectionProvider;

            if (dataProtectionProvider != null)
            {
                manager.UserTokenProvider =
                    new DataProtectorTokenProvider <MyIdentityUser>(dataProtectionProvider.Create("ASP.NET Identity"));
            }
            return(manager);
        }
Exemple #2
0
 public ApplicationSignInManager(MyIdentityUserManager userManager, IAuthenticationManager authenticationManager)
     : base(userManager, authenticationManager)
 {
 }