App domain redirect (#4391)

* Fix duplicates in GetAllApps with allowNoUser

* Use domain mapping as canonical reference and redirect to it

* Revert domain mapping to hostname instead of URL
This commit is contained in:
d11n
2023-02-02 12:53:42 +01:00
committed by GitHub
parent 99299ba06f
commit 26248774c2
4 changed files with 58 additions and 38 deletions

View File

@@ -758,22 +758,21 @@ namespace BTCPayServer.Controllers
{
return Redirect(returnUrl);
}
else
{
// After login, if there is an app on "/", we should redirect to BTCPay explicit home route, and not to the app.
if (PoliciesSettings.RootAppId is not null && PoliciesSettings.RootAppType is not null)
return RedirectToAction(nameof(UIHomeController.Home), "UIHome");
if (PoliciesSettings.DomainToAppMapping is { } mapping)
{
var matchedDomainMapping = mapping.FirstOrDefault(item =>
item.Domain.Equals(this.HttpContext.Request.Host.Host, StringComparison.InvariantCultureIgnoreCase));
if (matchedDomainMapping is not null)
return RedirectToAction(nameof(UIHomeController.Home), "UIHome");
}
return RedirectToAction(nameof(UIHomeController.Index), "UIHome");
}
}
// After login, if there is an app on "/", we should redirect to BTCPay explicit home route, and not to the app.
if (PoliciesSettings.RootAppId is not null && PoliciesSettings.RootAppType is not null)
return RedirectToAction(nameof(UIHomeController.Home), "UIHome");
if (PoliciesSettings.DomainToAppMapping is { } mapping)
{
var matchedDomainMapping = mapping.FirstOrDefault(item =>
item.Domain.Equals(HttpContext.Request.Host.Host, StringComparison.InvariantCultureIgnoreCase));
if (matchedDomainMapping is not null)
return RedirectToAction(nameof(UIHomeController.Home), "UIHome");
}
return RedirectToAction(nameof(UIHomeController.Index), "UIHome");
}
private bool CanLoginOrRegister()
{