diff --git a/apps/api/src/admin-workspace.controller.ts b/apps/api/src/admin-workspace.controller.ts index 51d87d4..64409ba 100644 --- a/apps/api/src/admin-workspace.controller.ts +++ b/apps/api/src/admin-workspace.controller.ts @@ -171,13 +171,12 @@ class AdminWorkspaceController { @Body() body: InstallTemplateDto, ): Promise { this.requireAdmin(request); - return this.templateWorkspace.install(this.brandId(), body.templateKey); + return this.templateWorkspace.install(this.requireAdmin(request).brandId, body.templateKey); } @Get("capabilities") async listCapabilities(@Req() request: FastifyRequest): Promise { - this.requireAdmin(request); - const brandId = this.brandId(); + const brandId = this.requireAdmin(request).brandId; const [brand, installations] = await Promise.all([ this.prisma.brandProfile.findUnique({ where: { id: brandId }, @@ -203,8 +202,7 @@ class AdminWorkspaceController { @Get("sample-content/preview") async previewSampleContent(@Req() request: FastifyRequest): Promise { - this.requireAdmin(request); - const brandId = this.brandId(); + const brandId = this.requireAdmin(request).brandId; const [offerings, trustContent, fields] = await Promise.all([ this.prisma.offering.count({ where: { brandId } }), this.prisma.trustContent.count({ where: { brandId } }), @@ -220,7 +218,7 @@ class AdminWorkspaceController { @Post("sample-content/import") async importSampleContent(@Req() request: FastifyRequest): Promise { const identity = this.requireAdmin(request); - const brandId = this.brandId(); + const brandId = identity.brandId; const existing = await this.prisma.brandFieldDefinition.count({ where: { brandId, source: "sample" }, }); @@ -296,7 +294,7 @@ class AdminWorkspaceController { @Body() body: UpdateCapabilityInstallationDto, ): Promise { const identity = this.requireAdmin(request); - const brandId = this.brandId(); + const brandId = identity.brandId; const brand = await this.prisma.brandProfile.findUnique({ where: { id: brandId } }); const template = getBrandTemplate(brand?.templateKey ?? "personal"); if (!template?.capabilities.includes(key as never) && !(key in capabilityPlugins))