public void Configure(IApplicationBuilder app, CommonService service) { var authOptions = new CookieAuthenticationOptions { AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme, AutomaticAuthenticate = true, AutomaticChallenge = true, ExpireTimeSpan = TimeSpan.FromHours(5), Events = new CookieAuthenticationEvents { OnRedirectToLogin = context => { context.Response.StatusCode = (int) HttpStatusCode.Unauthorized; return Task.CompletedTask; } } }; // redirect to setup until configured app.MapWhen( ctx => ctx.Request.Path == "/" && !service.IsConfigured(), req => req.Run( ctx => Task.Run(() => ctx.Response.Redirect("/setup")) ) ); app.UseDefaultFiles() .UseStaticFiles() .UseCookieAuthentication(authOptions) .UseMvc(); CreateDatabase(app); }
public SettingsController(GamesContext db, CommonService service, AuthenticationService auth) { this.db = db; this.service = service; this.auth = auth; }
public UserController(GamesContext db, CommonService service) { this.db = db; this.service = service; }
public AuthenticationService(CommonService service) { this.service = service; }
public ImageController(GamesContext db, CommonService service, AuthenticationService auth, IHostingEnvironment env) { this.db = db; this.service = service; this.auth = auth; this.environment = env; }