Example #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);
        }
Example #2
0
        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();
        }
        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);
        }
Example #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();
        }
Example #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);
        }
Example #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();
        }
Example #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
            }
        }
Example #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);
        }
Example #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);
 }
Example #10
0
 public static bool IsAdministrator(this IPrincipal user)
 {
     UsersInitializer.Initialize();
     return(user.IsInRole(Constants.AdminRoleName));
 }