Exemple #1
0
        public static BackofficeUserManager Create(IdentityFactoryOptions <BackofficeUserManager> options,
                                                   IOwinContext context, int idApplication)
        {
            var manager = new BackofficeUserManager(new ApplicationUserStore(context.Get <ApplicationDbContext>(), idApplication));

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

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

            manager.UserLockoutEnabledByDefault          = false;
            manager.DefaultAccountLockoutTimeSpan        = TimeSpan.MinValue;
            manager.MaxFailedAccessAttemptsBeforeLockout = int.MaxValue;

            manager.RegisterTwoFactorProvider("PhoneCode", new PhoneNumberTokenProvider <ApplicationUser>
            {
                MessageFormat = "Your security code is: {0}"
            });

            manager.RegisterTwoFactorProvider("EmailCode", new EmailTokenProvider <ApplicationUser>
            {
                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 <ApplicationUser>(dataProtectionProvider.Create("ASP.NET Identity"));
            }

            return(manager);
        }
Exemple #2
0
 public ApplicationSignInManager(BackofficeUserManager userManager, IAuthenticationManager authenticationManager) : base(userManager, authenticationManager)
 {
 }