aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Startup.cs
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-10-31 15:02:03 +0800
committerGitHub <noreply@github.com>2019-10-31 15:02:03 +0800
commit2de7fa95bb5ad0a10f74fb390bac464a250dee42 (patch)
treeba42530cf4f13621a7a3a7ff661e383117119883 /Timeline/Startup.cs
parentf08f53d6fcd9baf9dd3b95209f7c7448ae8168d4 (diff)
parentcf2055f956695bc0b9ecdb6d8023d0d199b98462 (diff)
downloadtimeline-2de7fa95bb5ad0a10f74fb390bac464a250dee42.tar.gz
timeline-2de7fa95bb5ad0a10f74fb390bac464a250dee42.tar.bz2
timeline-2de7fa95bb5ad0a10f74fb390bac464a250dee42.zip
Merge pull request #53 from crupest/nickname
Add nickname support.
Diffstat (limited to 'Timeline/Startup.cs')
-rw-r--r--Timeline/Startup.cs18
1 files changed, 12 insertions, 6 deletions
diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs
index b44add6f..f6abf36d 100644
--- a/Timeline/Startup.cs
+++ b/Timeline/Startup.cs
@@ -8,9 +8,10 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System.Collections.Generic;
using System.Globalization;
-using Timeline.Authentication;
+using Timeline.Auth;
using Timeline.Configs;
using Timeline.Entities;
+using Timeline.Formatters;
using Timeline.Helpers;
using Timeline.Services;
@@ -31,17 +32,22 @@ namespace Timeline
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
- services.AddControllers()
+ services.AddControllers(setup =>
+ {
+ setup.InputFormatters.Add(new StringInputFormatter());
+ })
.ConfigureApiBehaviorOptions(options =>
{
options.InvalidModelStateResponseFactory = InvalidModelResponseFactory.Factory;
})
- .AddNewtonsoftJson();
+ .AddNewtonsoftJson(); // TODO: Remove this.
services.Configure<JwtConfig>(Configuration.GetSection(nameof(JwtConfig)));
var jwtConfig = Configuration.GetSection(nameof(JwtConfig)).Get<JwtConfig>();
- services.AddAuthentication(AuthConstants.Scheme)
- .AddScheme<AuthOptions, AuthHandler>(AuthConstants.Scheme, AuthConstants.DisplayName, o => { });
+ services.AddAuthentication(AuthenticationConstants.Scheme)
+ .AddScheme<MyAuthenticationOptions, MyAuthenticationHandler>(AuthenticationConstants.Scheme, AuthenticationConstants.DisplayName, o => { });
+ services.AddAuthorization();
+
var corsConfig = Configuration.GetSection("Cors").Get<string[]>();
services.AddCors(setup =>
@@ -62,8 +68,8 @@ namespace Timeline
services.AddScoped<IJwtService, JwtService>();
services.AddTransient<IPasswordService, PasswordService>();
services.AddTransient<IClock, Clock>();
-
services.AddUserAvatarService();
+ services.AddScoped<IUserDetailService, UserDetailService>();
var databaseConfig = Configuration.GetSection(nameof(DatabaseConfig)).Get<DatabaseConfig>();