Skip to content

Commit

Permalink
fix: Add missing authorization to some endpoints (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-dudarev authored Sep 18, 2024
1 parent 1589d86 commit b4f9d32
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,12 @@ public async Task<ActionResult> GetInvoicePdf(string orderNumber)
throw new InvalidOperationException($"Cannot find order with number {orderNumber}");
}

var authorizationResult = await _authorizationService.AuthorizeAsync(User, order, new OrderAuthorizationRequirement(ModuleConstants.Security.Permissions.Read));
if (!authorizationResult.Succeeded)
{
return Forbid();
}

var notification = await _notificationSearchService.GetNotificationAsync<InvoiceEmailNotification>(new TenantIdentity(order.StoreId, nameof(Store)));
notification.CustomerOrder = order;
notification.LanguageCode = order.LanguageCode;
Expand Down Expand Up @@ -718,6 +724,12 @@ public ActionResult GetOrderFullTextSearchEnabled()
[Route("indexed/search")]
public async Task<ActionResult<CustomerOrderSearchResult>> SearchCustomerOrderIndexed([FromBody] CustomerOrderIndexedSearchCriteria criteria)
{
var authorizationResult = await _authorizationService.AuthorizeAsync(User, criteria, new OrderAuthorizationRequirement(ModuleConstants.Security.Permissions.Read));
if (!authorizationResult.Succeeded)
{
return Forbid();
}

var result = await _indexedSearchService.SearchCustomerOrdersAsync(criteria);
return Content(JsonConvert.SerializeObject(result, _outputJsonSerializerSettings), "application/json");
}
Expand Down

0 comments on commit b4f9d32

Please sign in to comment.