public void ConfigureServices(IServiceCollection services) { services.AddMvc() .SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_2_1); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddSingleton <IPasswordHasher, PasswordHasher>(); services.AddSingleton <UserRepository>(); services.AddSingleton <DocumentRepository>(); services.AddSingleton <CurrentUserProvider>(); services.AddSingleton(serviceProvider => { var env = serviceProvider.GetRequiredService <IHostingEnvironment>(); var db = new PasswordManagerDatabase(Path.Combine(env.ContentRootPath, "db", "PasswordManager.json")); db.Load(); return(db); }); services.Configure <JwtAuthentication>(Configuration.GetSection("JwtAuthentication")); services.AddSingleton <IPostConfigureOptions <JwtBearerOptions>, ConfigureJwtBearerOptions>(); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(); }
public IActionResult Reload() { _passwordManagerDatabase.Load(); return(Ok()); }