Exemple #1
0
        public static UygulamaKullaniciYoneticisi Olustur(IdentityFactoryOptions <UygulamaKullaniciYoneticisi> options, IOwinContext context)
        {
            var yonetici = new UygulamaKullaniciYoneticisi(new UserStore <UygulamaKullanici>(context.Get <UygulamaDbContext>()));

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

            // Configure validation logic for passwords
            yonetici.PasswordValidator = new PasswordValidator
            {
                RequiredLength          = 6,
                RequireNonLetterOrDigit = true,
                RequireDigit            = true,
                RequireLowercase        = true,
                RequireUppercase        = true,
            };

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

            // 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 it in here.
            yonetici.RegisterTwoFactorProvider("Phone Code", new PhoneNumberTokenProvider <UygulamaKullanici>
            {
                MessageFormat = "Your security code is {0}"
            });
            yonetici.RegisterTwoFactorProvider("Email Code", new EmailTokenProvider <UygulamaKullanici>
            {
                Subject    = "Security Code",
                BodyFormat = "Your security code is {0}"
            });
            yonetici.EmailService = new EpostaServisi();
            yonetici.SmsService   = new SmsServisi();
            var dataProtectionProvider = options.DataProtectionProvider;

            if (dataProtectionProvider != null)
            {
                yonetici.UserTokenProvider =
                    new DataProtectorTokenProvider <UygulamaKullanici>(dataProtectionProvider.Create("ASP.NET Identity"));
            }
            return(yonetici);
        }
        public static UygulamaKullaniciYoneticisi Olustur(IdentityFactoryOptions <UygulamaKullaniciYoneticisi> options, IOwinContext context)
        {
            var yonetici = new UygulamaKullaniciYoneticisi(new UserStore <UygulamaKullanici>(context.Get <UygulamaDbContext>()));

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


            yonetici.PasswordValidator = new PasswordValidator
            {
                RequiredLength          = 6,
                RequireNonLetterOrDigit = true,
                RequireDigit            = true,
                RequireLowercase        = true,
                RequireUppercase        = true,
            };


            yonetici.UserLockoutEnabledByDefault          = true;
            yonetici.DefaultAccountLockoutTimeSpan        = TimeSpan.FromMinutes(5);
            yonetici.MaxFailedAccessAttemptsBeforeLockout = 5;


            yonetici.RegisterTwoFactorProvider("Phone Code", new PhoneNumberTokenProvider <UygulamaKullanici>
            {
                MessageFormat = "Your security code is {0}"
            });
            yonetici.RegisterTwoFactorProvider("Email Code", new EmailTokenProvider <UygulamaKullanici>
            {
                Subject    = "Security Code",
                BodyFormat = "Your security code is {0}"
            });
            yonetici.EmailService = new EpostaServisi();
            yonetici.SmsService   = new SmsServisi();
            var dataProtectionProvider = options.DataProtectionProvider;

            if (dataProtectionProvider != null)
            {
                yonetici.UserTokenProvider =
                    new DataProtectorTokenProvider <UygulamaKullanici>(dataProtectionProvider.Create("ASP.NET Identity"));
            }
            return(yonetici);
        }