Skip to content

Commit

Permalink
Moved the dependency of ICustomerDeviceRepository to Invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
nagarwal4 committed Mar 7, 2024
1 parent 83454b4 commit 814a13f
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,18 @@ namespace Core.API.ResponseHandling;
/// </summary>
public class PublicKeyLinkedMiddleware
{
private readonly ICustomerDeviceRepository _customerDeviceRepository;
private readonly RequestDelegate _next;
private readonly ILogger<PublicKeyLinkedMiddleware> _logger;

public PublicKeyLinkedMiddleware(
ICustomerDeviceRepository customerDeviceRepository,
RequestDelegate next,
ILogger<PublicKeyLinkedMiddleware> logger)
{
_customerDeviceRepository = customerDeviceRepository;
_next = next;
_logger = logger;
}

public async Task Invoke(HttpContext context)
public async Task Invoke(HttpContext context, ICustomerDeviceRepository customerDeviceRepository)
{
// skip the middleware for specific endpoints
if (!SkipEndpoint(context))
Expand All @@ -40,7 +37,7 @@ public async Task Invoke(HttpContext context)
var pubKey = context.Request.Headers["x-public-key"];

// get all public keys linked to the user
var customerDevices = await _customerDeviceRepository.GetAsync(userId, context.RequestAborted);
var customerDevices = await customerDeviceRepository.GetAsync(userId, context.RequestAborted);

// if the user does not have any public keys or the public key is not linked to the user, return forbidden
if (customerDevices is null
Expand Down

0 comments on commit 814a13f

Please sign in to comment.