Beispiel #1
0
        public static void Initialize(BudgetJarsDbContext context)
        {
            context.Database.EnsureCreated();

            if (context.Users.Count() == 0)
            {
                context.Users.Add(new DAL.User()
                {
                    DateOfBirth = DateTime.Now,
                    Email       = "*****@*****.**",
                    FirstName   = "Taras",
                    LastName    = "Kuzyna"
                });
                context.SaveChanges();
            }
        }
Beispiel #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, BudgetJarsDbContext context)
        {
            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseApplicationInsightsRequestTelemetry();

            app.UseApplicationInsightsExceptionTelemetry();

            app.UseCookieAuthentication(new CookieAuthenticationOptions()
            {
                AuthenticationScheme  = "Cookies",
                AutomaticAuthenticate = true
            });

            app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions()
            {
                AuthenticationScheme          = "oidc",
                SignInScheme                  = "Cookies",
                Authority                     = "https://accounts.google.com",
                ResponseType                  = "code id_token",
                ClientId                      = "{Replace with your Google Client ID}",
                ClientSecret                  = "{Replace with your Google Client Secret}",
                GetClaimsFromUserInfoEndpoint = true,
                SaveTokens                    = true
            });

            app.UseMvc();

            DbInitializer.Initialize(context);
        }