예제 #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, UserManager <MyUser> userManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });

            UsersInitializer.SeedUsers(userManager);
        }
예제 #2
0
파일: Program.cs 프로젝트: olehspidey/B2B
        public static async Task Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var serviceProvider = scope.ServiceProvider;
                var rolesManager    = serviceProvider.GetService <RoleManager <IdentityRole> >();
                var userManager     = serviceProvider.GetService <UserManager <User> >();
                var configuration   = serviceProvider.GetService <IConfiguration>();

                try
                {
                    await RolesInitializer.Seed(configuration, rolesManager);

                    await UsersInitializer.Seed(configuration, userManager);
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                }
            }

            host.Run();
        }
예제 #3
0
        protected void Application_Start()
        {
            Initialize();
            Context context = ApplicationStartContext();
            var     log     = new SysLogModel(context: context);

            UsersInitializer.Initialize(context: context);
            StatusesMigrator.Migrate(context: context);
            StatusesInitializer.Initialize(context: context);
            SetConfigrations();
            SiteInfo.Reflesh(context: context);
            log.Finish(context: context);
        }
예제 #4
0
        private void InitializeLog()
        {
            var log = new SysLogModel();

            SiteInfo.TenantCaches.Add(0, new TenantCache(0));
            SiteInfo.Reflesh();
            UsersInitializer.Initialize();
            ItemsInitializer.Initialize();
            StatusesMigrator.Migrate();
            SiteSettingsMigrator.Migrate();
            StatusesInitializer.Initialize();
            log.Finish();
        }
예제 #5
0
        private void InitializeLog()
        {
            ContextImplement context = ApplicationStartContext();
            var log = new SysLogModel(context: context);

            UsersInitializer.Initialize(context: context);
            ItemsInitializer.Initialize(context: context);
            StatusesMigrator.Migrate(context: context);
            SiteSettingsMigrator.Migrate(context: context);
            StatusesInitializer.Initialize(context: context);
            SetConfigrations(context: context);
            SiteInfo.Reflesh(context: context);
            log.Finish(context: context);
        }
예제 #6
0
        protected void Application_Start()
        {
            Application["StartTime"]      = DateTime.Now;
            Application["LastAccessTime"] = Application["StartTime"];
            Initialize();
            var log = new SysLogModel();

            SiteInfo.TenantCaches.Add(0, new TenantCache(0));
            SiteInfo.Reflesh();
            UsersInitializer.Initialize();
            ItemsInitializer.Initialize();
            StatusesMigrator.Migrate();
            SiteSettingsMigrator.Migrate();
            StatusesInitializer.Initialize();
            SetConfigrations();
            log.Finish();
        }
예제 #7
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env,
                              GmmContext context, ApplicationDbContext idContext,
                              RoleManager <ApplicationRole> roleManager,
                              UserManager <ApplicationUser> userManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            //app.UseCookiePolicy(); //Removed cookie warning

            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "areas",
                    template: "{area:exists}/{controller=Home}/{action=Index}/{id?}"
                    );
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            DbInitializer.Initialize(context);
            try
            {
                UsersInitializer.Initialize(idContext, userManager, roleManager).Wait();
            }
            catch (System.AggregateException ae)
            {
                //SqlException: Invalid object name 'AspNetRoles'
                //Identity tabbellen worden niet aangemaakt bij nieuwe database.
                //Oplossing: Update-Database
            }
        }
예제 #8
0
        protected void Application_Start()
        {
            Initialize();
            Context context = new Context(tenantId: 0)
            {
                Controller = "Global.asax",
                Action     = "Application_Start",
            };
            var log = new SysLogModel(context: context);

            ExtensionInitializer.Initialize(context: context);
            UsersInitializer.Initialize(context: context);
            StatusesMigrator.Migrate(context: context);
            StatusesInitializer.Initialize(context: context);
            NotificationInitializer.Initialize();
            SetConfigrations();
            SiteInfo.Reflesh(context: context);
            log.Finish(context: context);
        }
예제 #9
0
 /// <summary>
 /// Called by runtime and used to configure the HTTP request pipeline.
 /// </summary>
 public void Configure(IApplicationBuilder app, IHostingEnvironment environment, SaycleContext context, RolesInitializer rolesInitializer, LanguagesInitializer languagesInitializer, UsersInitializer userInitializer)
 {
     if (environment.IsDevelopment())
     {
         app.UseDeveloperExceptionPage();
     }
     app.UseSwagger();
     app.UseSwaggerUI(o =>
     {
         o.SwaggerEndpoint($"/swagger/{ConfigurationProvider.Version}/swagger.json", $"{ConfigurationProvider.ApplicationName} {ConfigurationProvider.Version}");
     });
     app.UseAuthentication();
     app.UseMvc();
     InitializeData(context, rolesInitializer, languagesInitializer, userInitializer);
 }
예제 #10
0
 public static bool IsAdministrator(this IPrincipal user)
 {
     UsersInitializer.Initialize();
     return(user.IsInRole(Constants.AdminRoleName));
 }