diff options
author | crupest <crupest@outlook.com> | 2020-02-21 15:10:37 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-02-21 15:10:37 +0800 |
commit | f389661667a510d6accfb412482578b66527e6e4 (patch) | |
tree | 57a8579bc8b6d2be2831c8e55d5b5b0f552def35 /Timeline/Startup.cs | |
parent | 3fa9899e17df4b1012e8b645915ac15022b84f9b (diff) | |
download | timeline-f389661667a510d6accfb412482578b66527e6e4.tar.gz timeline-f389661667a510d6accfb412482578b66527e6e4.tar.bz2 timeline-f389661667a510d6accfb412482578b66527e6e4.zip |
Move jwt token key from configuration to database and auto generatable.
Diffstat (limited to 'Timeline/Startup.cs')
-rw-r--r-- | Timeline/Startup.cs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs index f305c39d..14bd14cc 100644 --- a/Timeline/Startup.cs +++ b/Timeline/Startup.cs @@ -9,7 +9,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
using System;
-using System.IO;
using System.Text.Json.Serialization;
using Timeline.Auth;
using Timeline.Configs;
@@ -84,6 +83,8 @@ namespace Timeline });
}
+ services.AddScoped<IPathProvider, PathProvider>();
+
services.AddAutoMapper(GetType().Assembly);
services.AddTransient<IClock, Clock>();
@@ -99,10 +100,10 @@ namespace Timeline services.TryAddSingleton<IActionContextAccessor, ActionContextAccessor>();
- var dbConnectionString = $"Data Source={Path.Combine(workDir, "timeline.db")}";
- services.AddDbContext<DatabaseContext>(options =>
+ services.AddDbContext<DatabaseContext>((services, options )=>
{
- options.UseSqlite(dbConnectionString);
+ var pathProvider = services.GetRequiredService<IPathProvider>();
+ options.UseSqlite($"Data Source={pathProvider.GetDatabaseFilePath()}");
});
}
|