mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
POS: Fix form redirect in conjunction with root path setting (#6506)
* POS: Fix form redirect in conjunction with root path setting Fixes #6493 and also adds missing status messages on the forms pages. * Fix other occurrences
This commit is contained in:
@@ -104,10 +104,15 @@ public static class HttpRequestExtensions
|
|||||||
return isRelative ? request.GetAbsoluteRoot() + redirectUrl : redirectUrl;
|
return isRelative ? request.GetAbsoluteRoot() + redirectUrl : redirectUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Uri GetAbsoluteUriNoPathBase(this HttpRequest request, string relativeOrAbsolute)
|
||||||
|
{
|
||||||
|
return GetAbsoluteUriNoPathBase(request, new Uri(relativeOrAbsolute, UriKind.RelativeOrAbsolute));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Will return an absolute URL.
|
/// Will return an absolute URL.
|
||||||
/// If `relativeOrAsbolute` is absolute, returns it.
|
/// If `relativeOrAbsolute` is absolute, returns it.
|
||||||
/// If `relativeOrAsbolute` is relative, send absolute url based on the HOST of this request (without PathBase)
|
/// If `relativeOrAbsolute` is relative, send absolute url based on the HOST of this request (without PathBase)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <param name="relativeOrAbsolte"></param>
|
/// <param name="relativeOrAbsolte"></param>
|
||||||
|
|||||||
@@ -171,9 +171,10 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||||||
var allowedPayjoin = derivationScheme.IsHotWallet && Store.GetStoreBlob().PayJoinEnabled;
|
var allowedPayjoin = derivationScheme.IsHotWallet && Store.GetStoreBlob().PayJoinEnabled;
|
||||||
if (allowedPayjoin)
|
if (allowedPayjoin)
|
||||||
{
|
{
|
||||||
bip21.QueryParams.Add(PayjoinClient.BIP21EndpointKey,
|
var endpoint = Request.GetAbsoluteUriNoPathBase(
|
||||||
Request.GetAbsoluteUri(Url.Action(nameof(PayJoinEndpointController.Submit), "PayJoinEndpoint",
|
Url.Action(nameof(PayJoinEndpointController.Submit), "PayJoinEndpoint",
|
||||||
new { network.CryptoCode })));
|
new { network.CryptoCode })).ToString();
|
||||||
|
bip21.QueryParams.Add(PayjoinClient.BIP21EndpointKey, endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(new OnChainWalletAddressData()
|
return Ok(new OnChainWalletAddressData()
|
||||||
|
|||||||
@@ -697,7 +697,7 @@ namespace BTCPayServer.Controllers
|
|||||||
var lnConfig = _LnConfigProvider.GetConfig(configKey);
|
var lnConfig = _LnConfigProvider.GetConfig(configKey);
|
||||||
if (lnConfig != null)
|
if (lnConfig != null)
|
||||||
{
|
{
|
||||||
model.QRCodeLink = Request.GetAbsoluteUri(Url.Action(nameof(GetLNDConfig), new { configKey = configKey }));
|
model.QRCodeLink = Request.GetAbsoluteUriNoPathBase(Url.Action(nameof(GetLNDConfig), new { configKey })).ToString();
|
||||||
model.QRCode = $"config={model.QRCodeLink}";
|
model.QRCode = $"config={model.QRCodeLink}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -404,9 +404,10 @@ namespace BTCPayServer.Controllers
|
|||||||
var bip21 = network.GenerateBIP21(address?.ToString(), null);
|
var bip21 = network.GenerateBIP21(address?.ToString(), null);
|
||||||
if (allowedPayjoin)
|
if (allowedPayjoin)
|
||||||
{
|
{
|
||||||
bip21.QueryParams.Add(PayjoinClient.BIP21EndpointKey,
|
var endpoint = Request.GetAbsoluteUriNoPathBase(
|
||||||
Request.GetAbsoluteUri(Url.Action(nameof(PayJoinEndpointController.Submit), "PayJoinEndpoint",
|
Url.Action(nameof(PayJoinEndpointController.Submit), "PayJoinEndpoint",
|
||||||
new { cryptoCode = walletId.CryptoCode })));
|
new { cryptoCode = walletId.CryptoCode })).ToString();
|
||||||
|
bip21.QueryParams.Add(PayjoinClient.BIP21EndpointKey, endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
string[]? labels = null;
|
string[]? labels = null;
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers
|
|||||||
RedirectAutomatically = settings.RedirectAutomatically,
|
RedirectAutomatically = settings.RedirectAutomatically,
|
||||||
RedirectURL = !string.IsNullOrEmpty(redirectUrl) ? redirectUrl
|
RedirectURL = !string.IsNullOrEmpty(redirectUrl) ? redirectUrl
|
||||||
: !string.IsNullOrEmpty(settings.RedirectUrl) ? settings.RedirectUrl
|
: !string.IsNullOrEmpty(settings.RedirectUrl) ? settings.RedirectUrl
|
||||||
: Request.GetAbsoluteUri(Url.Action(nameof(ViewPointOfSale), "UIPointOfSale", new { appId, viewType })),
|
: Request.GetAbsoluteUriNoPathBase(Url.Action(nameof(ViewPointOfSale), "UIPointOfSale", new { appId, viewType })).ToString(),
|
||||||
PaymentMethods = paymentMethods?.Where(p => p.Value.Enabled).Select(p => p.Key).ToArray()
|
PaymentMethods = paymentMethods?.Where(p => p.Value.Enabled).Select(p => p.Key).ToArray()
|
||||||
},
|
},
|
||||||
AdditionalSearchTerms = new[] { AppService.GetAppSearchTerm(app) }
|
AdditionalSearchTerms = new[] { AppService.GetAppSearchTerm(app) }
|
||||||
@@ -534,7 +534,7 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers
|
|||||||
{
|
{
|
||||||
var controller = nameof(UIPointOfSaleController).TrimEnd("Controller", StringComparison.InvariantCulture);
|
var controller = nameof(UIPointOfSaleController).TrimEnd("Controller", StringComparison.InvariantCulture);
|
||||||
var redirectUrl =
|
var redirectUrl =
|
||||||
Request.GetAbsoluteUri(Url.Action(nameof(ViewPointOfSale), controller, new { appId, viewType }));
|
Request.GetAbsoluteUriNoPathBase(Url.Action(nameof(ViewPointOfSale), controller, new { appId, viewType })).ToString();
|
||||||
formParameters.Add("formResponse", FormDataService.GetValues(form).ToString());
|
formParameters.Add("formResponse", FormDataService.GetValues(form).ToString());
|
||||||
return View("PostRedirect", new PostRedirectViewModel
|
return View("PostRedirect", new PostRedirectViewModel
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ Vue.component("lnurl-withdraw-checkout", {
|
|||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
url: @Safe.Json(Context.Request.GetAbsoluteUri(Url.Action("SubmitLNURLWithdrawForInvoice", "NFC"))),
|
url: @Safe.Json(Context.Request.GetAbsoluteUriNoPathBase(Url.Action("SubmitLNURLWithdrawForInvoice", "NFC")).ToString()),
|
||||||
amount: 0,
|
amount: 0,
|
||||||
submitting: false
|
submitting: false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
Create Form
|
Create Form
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
<partial name="_StatusMessage" />
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xxl-constrain col-xl-10">
|
<div class="col-xxl-constrain col-xl-10">
|
||||||
|
|||||||
@@ -215,6 +215,7 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<partial name="_StatusMessage" />
|
||||||
<div class="row mb-4">
|
<div class="row mb-4">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
@if (!ViewContext.ModelState.IsValid)
|
@if (!ViewContext.ModelState.IsValid)
|
||||||
|
|||||||
Reference in New Issue
Block a user