mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Remove anonymous access to invoice data
This commit is contained in:
@@ -40,16 +40,18 @@ namespace BTCPayServer.Controllers
|
|||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("invoices/{id}")]
|
[Route("invoices/{id}")]
|
||||||
[AllowAnonymous]
|
public async Task<DataWrapper<InvoiceResponse>> GetInvoice(string id)
|
||||||
public async Task<DataWrapper<InvoiceResponse>> GetInvoice(string id, string token)
|
|
||||||
{
|
{
|
||||||
var invoice = await _InvoiceRepository.GetInvoice(null, id);
|
var invoice = (await _InvoiceRepository.GetInvoices(new InvoiceQuery()
|
||||||
|
{
|
||||||
|
InvoiceId = id,
|
||||||
|
StoreId = new[] { HttpContext.GetStoreData().Id }
|
||||||
|
})).FirstOrDefault();
|
||||||
if (invoice == null)
|
if (invoice == null)
|
||||||
throw new BitpayHttpException(404, "Object not found");
|
throw new BitpayHttpException(404, "Object not found");
|
||||||
var resp = invoice.EntityToDTO(_NetworkProvider);
|
var resp = invoice.EntityToDTO(_NetworkProvider);
|
||||||
return new DataWrapper<InvoiceResponse>(resp);
|
return new DataWrapper<InvoiceResponse>(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("invoices")]
|
[Route("invoices")]
|
||||||
public async Task<DataWrapper<InvoiceResponse[]>> GetInvoices(
|
public async Task<DataWrapper<InvoiceResponse[]>> GetInvoices(
|
||||||
|
|||||||
@@ -30,11 +30,13 @@ namespace BTCPayServer.Controllers
|
|||||||
{
|
{
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("invoices/{invoiceId}")]
|
[Route("invoices/{invoiceId}")]
|
||||||
|
[Authorize(AuthenticationSchemes = Policies.CookieAuthentication)]
|
||||||
public async Task<IActionResult> Invoice(string invoiceId)
|
public async Task<IActionResult> Invoice(string invoiceId)
|
||||||
{
|
{
|
||||||
var invoice = (await _InvoiceRepository.GetInvoices(new InvoiceQuery()
|
var invoice = (await _InvoiceRepository.GetInvoices(new InvoiceQuery()
|
||||||
{
|
{
|
||||||
InvoiceId = invoiceId,
|
InvoiceId = invoiceId,
|
||||||
|
UserId = GetUserId(),
|
||||||
IncludeAddresses = true,
|
IncludeAddresses = true,
|
||||||
IncludeEvents = true
|
IncludeEvents = true
|
||||||
})).FirstOrDefault();
|
})).FirstOrDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user