From e70f7ee9f1f6723c307c3fff2fcb23617a623b90 Mon Sep 17 00:00:00 2001 From: Scott Pouliot Date: Wed, 13 May 2026 16:55:44 -0400 Subject: [PATCH] Fix kiosk logo: add anonymous Logo endpoint proxying blob storage CompanySettings/Logo requires tenant context and fails on anonymous kiosk pages. Added Kiosk/Logo which resolves the company from the KioskDevice cookie and proxies the blob directly. Co-Authored-By: Claude Sonnet 4.6 --- .../Controllers/KioskController.cs | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/PowderCoating.Web/Controllers/KioskController.cs b/src/PowderCoating.Web/Controllers/KioskController.cs index 700c2d9..6b18003 100644 --- a/src/PowderCoating.Web/Controllers/KioskController.cs +++ b/src/PowderCoating.Web/Controllers/KioskController.cs @@ -38,6 +38,7 @@ public class KioskController : Controller private readonly IEmailService _emailService; private readonly IHubContext _kioskHub; private readonly ILogger _logger; + private readonly ICompanyLogoService _logoService; /// Initialises all dependencies for the kiosk controller. public KioskController( @@ -47,7 +48,8 @@ public class KioskController : Controller IInAppNotificationService inApp, IEmailService emailService, IHubContext kioskHub, - ILogger logger) + ILogger logger, + ICompanyLogoService logoService) { _unitOfWork = unitOfWork; _mapper = mapper; @@ -56,6 +58,7 @@ public class KioskController : Controller _emailService = emailService; _kioskHub = kioskHub; _logger = logger; + _logoService = logoService; } // ========================================================================= @@ -83,6 +86,26 @@ public class KioskController : Controller return View(); } + /// + /// Serves the company logo for anonymous kiosk pages. Resolves the company from the + /// KioskDevice cookie so no tenant context is needed on the anonymous request. + /// + [AllowAnonymous] + [HttpGet, ResponseCache(Duration = 3600, Location = ResponseCacheLocation.Any)] + public async Task Logo() + { + var cookie = ReadKioskCookie(); + if (cookie == null) return NotFound(); + + var company = await _unitOfWork.Companies.GetByIdAsync(cookie.Value.companyId, ignoreQueryFilters: true); + if (company == null || string.IsNullOrEmpty(company.LogoFilePath)) return NotFound(); + + var (success, fileContent, contentType, _) = await _logoService.GetCompanyLogoAsync(company.LogoFilePath); + if (!success || fileContent.Length == 0) return NotFound(); + + return File(fileContent, contentType); + } + // ========================================================================= // DEVICE ACTIVATION (CompanyAdmin-only) // ========================================================================= @@ -648,7 +671,7 @@ public class KioskController : Controller { ViewBag.CompanyName = company.CompanyName; ViewBag.CompanyLogoUrl = !string.IsNullOrEmpty(company.LogoFilePath) - ? $"/CompanyLogo/{company.Id}" + ? Url.Action("Logo", "Kiosk") : null; ViewBag.WelcomeUrl = "/Kiosk/Welcome"; await Task.CompletedTask;