Add better error message if v1 routes are used.

This commit is contained in:
nicolas.dorier 2024-09-26 19:09:12 +09:00
parent 443a350bad
commit b5590a38fe
No known key found for this signature in database
GPG key ID: 6618763EF09186FE
2 changed files with 46 additions and 0 deletions

View file

@ -97,6 +97,9 @@ namespace BTCPayServer.Tests
Assert.NotNull(e.APIError.Message);
GreenfieldPermissionAPIError permissionError = Assert.IsType<GreenfieldPermissionAPIError>(e.APIError);
Assert.Equal(Policies.CanModifyStoreSettings, permissionError.MissingPermission);
var client = await user.CreateClient(Policies.CanViewStoreSettings);
await AssertAPIError("unsupported-in-v2", () => client.SendHttpRequest<object>($"api/v1/stores/{user.StoreId}/payment-methods/LightningNetwork"));
}
[Fact(Timeout = TestTimeout)]

View file

@ -0,0 +1,43 @@
using BTCPayServer.Abstractions.Constants;
using BTCPayServer.Abstractions.Extensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
namespace BTCPayServer.Controllers.GreenField
{
[ApiController]
[EnableCors(CorsPolicies.All)]
[Authorize(AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
public class GreenfieldObsoleteController : ControllerBase
{
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/LNURL")]
public IActionResult Obsolete1(string storeId)
{
return Obsolete();
}
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/LNURLPay/{cryptoCode}")]
[HttpDelete("~/api/v1/stores/{storeId}/payment-methods/LNURLPay/{cryptoCode}")]
[HttpPut("~/api/v1/stores/{storeId}/payment-methods/LNURLPay/{cryptoCode}")]
public IActionResult Obsolete2(string storeId, string cryptoCode)
{
return Obsolete();
}
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/LightningNetwork")]
public IActionResult Obsolete3(string storeId)
{
return Obsolete();
}
[HttpGet("~/api/v1/stores/{storeId}/payment-methods/LightningNetwork/{cryptoCode}")]
[HttpDelete("~/api/v1/stores/{storeId}/payment-methods/LightningNetwork/{cryptoCode}")]
[HttpPut("~/api/v1/stores/{storeId}/payment-methods/LightningNetwork/{cryptoCode}")]
public IActionResult Obsolete4(string storeId, string cryptoCode)
{
return Obsolete();
}
private IActionResult Obsolete()
{
return this.CreateAPIError(410, "unsupported-in-v2", "This route isn't supported by BTCPay Server 2.0 and newer. Please update your integration.");
}
}
}