diff --git a/backend/DramaLing.Api/Controllers/ImageGenerationController.cs b/backend/DramaLing.Api/Controllers/ImageGenerationController.cs index 9f7e732..b8dc3de 100644 --- a/backend/DramaLing.Api/Controllers/ImageGenerationController.cs +++ b/backend/DramaLing.Api/Controllers/ImageGenerationController.cs @@ -8,7 +8,7 @@ namespace DramaLing.Api.Controllers; [Route("api/[controller]")] [ApiController] -[Authorize] +[AllowAnonymous] // 暫時移除認證要求,與 FlashcardsController 保持一致 public class ImageGenerationController : ControllerBase { private readonly IImageGenerationOrchestrator _orchestrator; @@ -159,19 +159,23 @@ public class ImageGenerationController : ControllerBase private Guid GetCurrentUserId() { - var userIdClaim = User.FindFirst(ClaimTypes.NameIdentifier)?.Value - ?? User.FindFirst("sub")?.Value; + // 暫時使用固定測試用戶 ID,與 FlashcardsController 保持一致 + return Guid.Parse("E0A7DFA1-6B8A-4BD8-812C-54D7CBFAA394"); - if (string.IsNullOrEmpty(userIdClaim)) - { - throw new UnauthorizedAccessException("User ID not found in token"); - } - - if (!Guid.TryParse(userIdClaim, out var userId)) - { - throw new UnauthorizedAccessException("Invalid user ID format in token"); - } - - return userId; + // TODO: 恢復真實認證後改回 JWT Token 解析 + // var userIdClaim = User.FindFirst(ClaimTypes.NameIdentifier)?.Value + // ?? User.FindFirst("sub")?.Value; + // + // if (string.IsNullOrEmpty(userIdClaim)) + // { + // throw new UnauthorizedAccessException("User ID not found in token"); + // } + // + // if (!Guid.TryParse(userIdClaim, out var userId)) + // { + // throw new UnauthorizedAccessException("Invalid user ID format in token"); + // } + // + // return userId; } } \ No newline at end of file