Exemple #1
0
        public static CustomUserManager Create(IdentityFactoryOptions <CustomUserManager> options, IOwinContext context)
        {
            var manager = new CustomUserManager(new CustomUserStore());

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

            manager.RegisterTwoFactorProvider("Phone Code", new PhoneNumberTokenProvider <CustomUser>
            {
                MessageFormat = "Your security code is {0}"
            });

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

            return(manager);
        }
Exemple #2
0
        public async Task <ClaimsIdentity> GenerateUserIdentityAsync(CustomUserManager manager)
        {
            // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
            var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);

            // Add custom user claims here
            return(userIdentity);
        }
Exemple #3
0
 public CustomSignInManager(CustomUserManager userManager, IAuthenticationManager authenticationManager)
     : base(userManager, authenticationManager)
 {
 }