File tree Expand file tree Collapse file tree
src/SimpleToDoService/Middleware Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,31 +10,29 @@ namespace SimpleToDoService.Middleware
1010 public class CheckUserMiddleware
1111 {
1212 private readonly RequestDelegate next ;
13- private IToDoRepository repository ;
1413
1514 public CheckUserMiddleware ( ) { }
1615
17- public CheckUserMiddleware ( RequestDelegate next , IToDoRepository repository )
16+ public CheckUserMiddleware ( RequestDelegate next )
1817 {
1918 this . next = next ;
20- this . repository = repository ;
2119 }
2220
2321 public void Configure ( IApplicationBuilder applicationBuilder )
2422 {
2523 applicationBuilder . UseMiddleware < CheckUserMiddleware > ( ) ;
2624 }
2725
28- public async System . Threading . Tasks . Task Invoke ( HttpContext context )
26+ public async System . Threading . Tasks . Task Invoke ( HttpContext context , IToDoRepository repository )
2927 {
3028 if ( context . User . Identity . IsAuthenticated && ! context . Items . Keys . Contains ( "UserUuid" ) )
3129 {
32- context . Items . Add ( "UserUuid" , LoadUserGuid ( context ) ) ;
30+ context . Items . Add ( "UserUuid" , LoadUserGuid ( context , repository ) ) ;
3331 }
3432 await next . Invoke ( context ) ;
3533 }
3634
37- private Guid LoadUserGuid ( HttpContext context )
35+ private Guid LoadUserGuid ( HttpContext context , IToDoRepository repository )
3836 {
3937 var providerId = context . User . Claims . FirstOrDefault ( c => c . Type == ClaimTypes . NameIdentifier ) . Value ;
4038 var currentUser = repository . UserByProviderId ( providerId ) ;
You can’t perform that action at this time.
0 commit comments