From 609ec0989ff5b8ed3032d968883afe63aeb8f214 Mon Sep 17 00:00:00 2001 From: Nicolas Dorier Date: Fri, 27 Oct 2023 17:16:36 +0900 Subject: [PATCH] Do not activate Blazor in Wizard screens (#5435) --- .../Extensions/ViewsRazor.cs | 9 ++++++ BTCPayServer/Views/Shared/LayoutFoot.cshtml | 2 +- .../Views/Shared/_LayoutWizard.cshtml | 5 +-- .../ViewPaymentRequest.cshtml | 1 + .../UIPullPayment/ViewPullPayment.cshtml | 31 ++++++++++--------- BTCPayServer/_ViewImports.cshtml | 1 + 6 files changed, 31 insertions(+), 18 deletions(-) diff --git a/BTCPayServer.Abstractions/Extensions/ViewsRazor.cs b/BTCPayServer.Abstractions/Extensions/ViewsRazor.cs index ac2c0e2db..4664d65ef 100644 --- a/BTCPayServer.Abstractions/Extensions/ViewsRazor.cs +++ b/BTCPayServer.Abstractions/Extensions/ViewsRazor.cs @@ -20,6 +20,15 @@ namespace BTCPayServer.Abstractions.Extensions Relative } + public static void SetBlazorAllowed(this ViewDataDictionary viewData, bool allowed) + { + viewData["BlazorAllowed"] = allowed; + } + public static bool IsBlazorAllowed(this ViewDataDictionary viewData) + { + return viewData["BlazorAllowed"] is not false; + } + public static void SetActivePage(this ViewDataDictionary viewData, T activePage, string title = null, string activeId = null) where T : IConvertible { diff --git a/BTCPayServer/Views/Shared/LayoutFoot.cshtml b/BTCPayServer/Views/Shared/LayoutFoot.cshtml index fee0f32c0..a377f3959 100644 --- a/BTCPayServer/Views/Shared/LayoutFoot.cshtml +++ b/BTCPayServer/Views/Shared/LayoutFoot.cshtml @@ -4,7 +4,7 @@ -@if (User.Identity.IsAuthenticated) +@if (User.Identity.IsAuthenticated && ViewData.IsBlazorAllowed()) { } diff --git a/BTCPayServer/Views/Shared/_LayoutWizard.cshtml b/BTCPayServer/Views/Shared/_LayoutWizard.cshtml index 99ec4779d..756fd919d 100644 --- a/BTCPayServer/Views/Shared/_LayoutWizard.cshtml +++ b/BTCPayServer/Views/Shared/_LayoutWizard.cshtml @@ -1,5 +1,6 @@ -@{ - Layout = "_LayoutSimple"; +@{ + Layout = "_LayoutSimple"; + ViewData.SetBlazorAllowed(false); } @section PageHeadContent { diff --git a/BTCPayServer/Views/UIPaymentRequest/ViewPaymentRequest.cshtml b/BTCPayServer/Views/UIPaymentRequest/ViewPaymentRequest.cshtml index a26a607df..0cfb37f67 100644 --- a/BTCPayServer/Views/UIPaymentRequest/ViewPaymentRequest.cshtml +++ b/BTCPayServer/Views/UIPaymentRequest/ViewPaymentRequest.cshtml @@ -27,6 +27,7 @@ return status.ToString().ToLowerInvariant(); } } + ViewData.SetBlazorAllowed(false); } diff --git a/BTCPayServer/Views/UIPullPayment/ViewPullPayment.cshtml b/BTCPayServer/Views/UIPullPayment/ViewPullPayment.cshtml index 4cfcbb03b..fae42242f 100644 --- a/BTCPayServer/Views/UIPullPayment/ViewPullPayment.cshtml +++ b/BTCPayServer/Views/UIPullPayment/ViewPullPayment.cshtml @@ -7,22 +7,23 @@ @inject DisplayFormatter DisplayFormatter @model BTCPayServer.Models.ViewPullPaymentModel @{ - ViewData["Title"] = Model.Title; + ViewData["Title"] = Model.Title; Csp.UnsafeEval(); - Layout = null; - string StatusTextClass(string status) - { - switch (status) - { - case "Completed": - case "In Progress": - return "bg-success"; - case "Cancelled": - return "bg-danger"; - default: - return "bg-warning"; - } - } + Layout = null; + string StatusTextClass(string status) + { + switch (status) + { + case "Completed": + case "In Progress": + return "bg-success"; + case "Cancelled": + return "bg-danger"; + default: + return "bg-warning"; + } + } + ViewData.SetBlazorAllowed(false); } diff --git a/BTCPayServer/_ViewImports.cshtml b/BTCPayServer/_ViewImports.cshtml index f080039ff..bf620175c 100644 --- a/BTCPayServer/_ViewImports.cshtml +++ b/BTCPayServer/_ViewImports.cshtml @@ -9,6 +9,7 @@ @using BTCPayServer.Models.StoreViewModels @using BTCPayServer.Data @using Microsoft.AspNetCore.Routing; +@using BTCPayServer.Abstractions.Extensions; @inject Safe Safe @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, BTCPayServer