aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Startup.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-04-13 13:06:05 +0800
committercrupest <crupest@outlook.com>2019-04-13 13:06:05 +0800
commit4f16c1d3dff716092e1a26e06e6cfbeec90c027c (patch)
tree8ecd711d2b1c97754b321ef0e0bc7de45d303cbd /Timeline/Startup.cs
parentfac5006e7eaf7f7bc23e92a2b3059d4f1b37fa07 (diff)
parent401a5b74696c471e5168e421e3de0db1e5f946a8 (diff)
downloadtimeline-4f16c1d3dff716092e1a26e06e6cfbeec90c027c.tar.gz
timeline-4f16c1d3dff716092e1a26e06e6cfbeec90c027c.tar.bz2
timeline-4f16c1d3dff716092e1a26e06e6cfbeec90c027c.zip
Merge branch '6-user' into separate
Diffstat (limited to 'Timeline/Startup.cs')
-rw-r--r--Timeline/Startup.cs19
1 files changed, 14 insertions, 5 deletions
diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs
index f7b2e64d..79c2f05a 100644
--- a/Timeline/Startup.cs
+++ b/Timeline/Startup.cs
@@ -1,15 +1,16 @@
+using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
-using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using System.Text;
using Timeline.Configs;
-using Timeline.Services;
-using Microsoft.AspNetCore.HttpOverrides;
using Timeline.Formatters;
+using Timeline.Models;
+using Timeline.Services;
namespace Timeline
{
@@ -67,8 +68,16 @@ namespace Timeline
o.TokenValidationParameters.IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(jwtConfig.SigningKey));
});
- services.AddSingleton<IUserService, UserService>();
- services.AddSingleton<IJwtService, JwtService>();
+ services.AddScoped<IUserService, UserService>();
+ services.AddScoped<IJwtService, JwtService>();
+ services.AddTransient<IPasswordService, PasswordService>();
+
+ var databaseConfig = Configuration.GetSection(nameof(DatabaseConfig)).Get<DatabaseConfig>();
+
+ services.AddDbContext<DatabaseContext>(options =>
+ {
+ options.UseMySql(databaseConfig.ConnectionString);
+ });
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.