Esempio n. 1
0
        public static CSPUserManager Create(IdentityFactoryOptions <CSPUserManager> options, IOwinContext context)
        {
            var manager = new CSPUserManager(new CSPUserStore(CoronaSupportPlatformDbContext.Create()));

            // Configure validation logic for usernames
            manager.UserValidator = new UserValidator <CSPUser, int>(manager)
            {
                AllowOnlyAlphanumericUserNames = false,
                RequireUniqueEmail             = true
            };
            // Configure validation logic for passwords
            manager.PasswordValidator = new PasswordValidator
            {
                RequiredLength          = 6,
                RequireNonLetterOrDigit = false,
                RequireDigit            = false,
                RequireLowercase        = false,
                RequireUppercase        = false,
            };
            // Register two factor authentication providers. This application uses Phone
            // and Emails as a step of receiving a code for verifying the user
            // You can write your own provider and plug in here.
            manager.RegisterTwoFactorProvider("PhoneCode",
                                              new PhoneNumberTokenProvider <CSPUser, int>
            {
                MessageFormat = "Your security code is: {0}"
            });
            manager.RegisterTwoFactorProvider("EmailCode",
                                              new EmailTokenProvider <CSPUser, int>
            {
                Subject    = "Security Code",
                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 <CSPUser, int>(dataProtectionProvider.Create("CSPIdentity"));
            }
            return(manager);
        }
Esempio n. 2
0
 public CSPSignInManager(CSPUserManager userManager, IAuthenticationManager authManager) : base(userManager, authManager)
 {
 }