diff --git a/docker-compose.v2.yml b/docker-compose.v2.yml index adf04d7..9e6f86b 100644 --- a/docker-compose.v2.yml +++ b/docker-compose.v2.yml @@ -297,7 +297,7 @@ services: gateway: condition: service_healthy healthcheck: - test: ["CMD-SHELL", "wget -qO- http://localhost:3000 || exit 1"] + test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:3000 || exit 1"] interval: 30s timeout: 10s retries: 3 diff --git a/services/identity/FlatRender.IdentitySvc/Application/Services/Interfaces/IPlanService.cs b/services/identity/FlatRender.IdentitySvc/Application/Services/Interfaces/IPlanService.cs index fe4d32b..dfc10e9 100644 --- a/services/identity/FlatRender.IdentitySvc/Application/Services/Interfaces/IPlanService.cs +++ b/services/identity/FlatRender.IdentitySvc/Application/Services/Interfaces/IPlanService.cs @@ -5,7 +5,7 @@ namespace FlatRender.IdentitySvc.Application.Services.Interfaces; public interface IPlanService { - Task> ListAsync(Guid tenantId, string? scope); + Task> ListAsync(Guid? tenantId, string? scope); Task GetByIdAsync(Guid planId); Task GetCurrentPlanAsync(Guid userId); Task PurchasePlanAsync(Guid userId, Guid tenantId, PurchasePlanRequest request); diff --git a/services/identity/FlatRender.IdentitySvc/Application/Services/PlanService.cs b/services/identity/FlatRender.IdentitySvc/Application/Services/PlanService.cs index ad18b33..1352b5a 100644 --- a/services/identity/FlatRender.IdentitySvc/Application/Services/PlanService.cs +++ b/services/identity/FlatRender.IdentitySvc/Application/Services/PlanService.cs @@ -10,7 +10,7 @@ namespace FlatRender.IdentitySvc.Application.Services; public class PlanService(IdentityDbContext db) : IPlanService { - public async Task> ListAsync(Guid tenantId, string? scope) + public async Task> ListAsync(Guid? tenantId, string? scope) { var query = db.Plans.Where(p => p.IsActive && p.DeletedAt == null && diff --git a/services/identity/FlatRender.IdentitySvc/Controllers/PlansController.cs b/services/identity/FlatRender.IdentitySvc/Controllers/PlansController.cs index 97d26fe..04cd2ce 100644 --- a/services/identity/FlatRender.IdentitySvc/Controllers/PlansController.cs +++ b/services/identity/FlatRender.IdentitySvc/Controllers/PlansController.cs @@ -11,15 +11,16 @@ namespace FlatRender.IdentitySvc.Controllers; [Authorize] public class PlansController(IPlanService planService) : ControllerBase { + [AllowAnonymous] [HttpGet("plans")] [ProducesResponseType(typeof(object), 200)] public async Task List([FromQuery] string? scope) { - var tenantId = GetTenantId(); - var plans = await planService.ListAsync(tenantId, scope); + var plans = await planService.ListAsync(GetTenantIdOrNull(), scope); return Ok(new { data = plans }); } + [AllowAnonymous] [HttpGet("plans/{planId:guid}")] [ProducesResponseType(typeof(PlanResponse), 200)] public async Task GetById(Guid planId) @@ -43,4 +44,7 @@ public class PlansController(IPlanService planService) : ControllerBase private Guid GetTenantId() => Guid.Parse(User.FindFirst("tenant_id")?.Value ?? throw new UnauthorizedAccessException()); + + private Guid? GetTenantIdOrNull() => User.FindFirst("tenant_id")?.Value is { } t && Guid.TryParse(t, out var id) + ? id : null; }