Skip to content

Commit ba2e018

Browse files
committed
Fix middleware
1 parent 273fefa commit ba2e018

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

RequestTests.paw

-435 Bytes
Binary file not shown.

src/SimpleToDoService/Middleware/CheckUserMiddleware.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)