Exemple #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            var connectionString = ConnectionStringsHelper.GetEnvironmentConnectionString();

            services.AddEntityFrameworkNpgsql()
            .AddDbContext <ApplicationDbContext>(options => options.UseNpgsql(connectionString));

            services.AddDefaultIdentity <IdentityUser>()
            .AddEntityFrameworkStores <ApplicationDbContext>();

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.Configure <IdentityOptions>(options =>
            {
                options.Password.RequireDigit           = true;
                options.Password.RequireLowercase       = true;
                options.Password.RequireNonAlphanumeric = false;
                options.Password.RequireUppercase       = true;
                options.Password.RequiredLength         = 8;
                options.Password.RequiredUniqueChars    = 1;
            });
        }
 public override string ToString()
 {
     return(ConnectionStringsHelper.ReplacePassword(ConnectionString, "********"));
 }
 public static string GetConnectionStringUsername(ConnectionString connectionString)
 {
     return(ConnectionStringsHelper.ExtractUsername(connectionString.GetConnectionString()));
 }