Exemplo n.º 1
0
        private static IServiceProvider ConfigureService(IServiceCollection services, string[] args)
        {
            var dbContextFactory = new DesignTimeDbContextFactory();

            services.AddLogging();
            services.AddScoped <ApplicationDbContext>(p => dbContextFactory.CreateDbContext(args));

            services.AddIdentity <User, Role>()
            .AddEntityFrameworkStores <ApplicationDbContext>()
            .AddDefaultTokenProviders();                 // protection provider responsible for generating an email confirmation token or a password reset token
            services.Configure <IdentityOptions>(options =>
            {
                // Password settings
                options.Password.RequireDigit           = true;
                options.Password.RequiredLength         = 8;
                options.Password.RequireNonAlphanumeric = false;
                options.Password.RequireUppercase       = true;
                options.Password.RequireLowercase       = false;

                // User settings
                options.User.RequireUniqueEmail = true;
            });

            // Build the IoC from the service collection
            return(services.BuildServiceProvider());
        }
Exemplo n.º 2
0
        public static IServiceProvider ConfigureService(IServiceCollection services, string[] args)
        {
            var dbContextFactory = new DesignTimeDbContextFactory();

            services.AddLogging();
            services.AddScoped <ApplicationDbContext>(p => dbContextFactory.CreateDbContext(args));
            services.AddIdentity <User, Role>()
            .AddEntityFrameworkStores <ApplicationDbContext>()
            .AddDefaultTokenProviders();

            services.Configure <IdentityOptions>(options => {
                options.Password.RequireDigit           = true;
                options.Password.RequiredLength         = 8;
                options.Password.RequireNonAlphanumeric = false;
                options.Password.RequireUppercase       = true;
                options.Password.RequireLowercase       = false;

                // User settings
                options.User.RequireUniqueEmail = true;
            });
            return(services.BuildServiceProvider());
        }