7519f474f3
CI/CD / CI · API (dotnet build + test) (push) Successful in 1m1s
CI/CD / CI · Admin API (dotnet build) (push) Successful in 46s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m6s
CI/CD / CI · Admin Web (tsc) (push) Successful in 35s
CI/CD / CI · Website (tsc) (push) Successful in 45s
CI/CD / CI · Koja (tsc) (push) Successful in 50s
CI/CD / Deploy · all services (push) Successful in 3m15s
The dashboard demo-data banner is shown to Owner and Manager, but the /demo/seed endpoint required strictly Owner, so a Manager clicking it got a silent 403 (the banner had no error handler) — appearing as 'nothing happens, no tables or items'. The endpoint now allows Owner or Manager, and the banner shows the error on failure. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Meezi.API.Services;
|
|
using Meezi.Core.Interfaces;
|
|
using Meezi.Shared;
|
|
|
|
namespace Meezi.API.Controllers;
|
|
|
|
[Route("api/cafes/{cafeId}/demo")]
|
|
[Authorize]
|
|
public class DemoSeedController : CafeApiControllerBase
|
|
{
|
|
private readonly IDemoSeedService _demoSeed;
|
|
|
|
public DemoSeedController(IDemoSeedService demoSeed)
|
|
{
|
|
_demoSeed = demoSeed;
|
|
}
|
|
|
|
/// <summary>Seeds demo menu, tables, and inventory for any café. Owner-only.</summary>
|
|
[HttpPost("seed")]
|
|
public async Task<IActionResult> Seed(
|
|
string cafeId,
|
|
ITenantContext tenant,
|
|
CancellationToken ct)
|
|
{
|
|
if (EnsureCafeAccess(cafeId, tenant) is { } denied) return denied;
|
|
// Demo data is a setup helper; Owner or Manager may run it (matches the
|
|
// dashboard banner, which is shown to both roles).
|
|
if (EnsureManager(tenant) is { } managerDenied) return managerDenied;
|
|
|
|
var result = await _demoSeed.SeedAsync(cafeId, ct);
|
|
return Ok(new ApiResponse<DemoSeedResult>(true, result));
|
|
}
|
|
}
|