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 <noreply@anthropic.com>
This commit is contained in:
@@ -38,6 +38,7 @@ public class KioskController : Controller
|
||||
private readonly IEmailService _emailService;
|
||||
private readonly IHubContext<KioskHub> _kioskHub;
|
||||
private readonly ILogger<KioskController> _logger;
|
||||
private readonly ICompanyLogoService _logoService;
|
||||
|
||||
/// <summary>Initialises all dependencies for the kiosk controller.</summary>
|
||||
public KioskController(
|
||||
@@ -47,7 +48,8 @@ public class KioskController : Controller
|
||||
IInAppNotificationService inApp,
|
||||
IEmailService emailService,
|
||||
IHubContext<KioskHub> kioskHub,
|
||||
ILogger<KioskController> logger)
|
||||
ILogger<KioskController> 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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
[AllowAnonymous]
|
||||
[HttpGet, ResponseCache(Duration = 3600, Location = ResponseCacheLocation.Any)]
|
||||
public async Task<IActionResult> 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;
|
||||
|
||||
Reference in New Issue
Block a user