From 8c3b61be235b2d86be8452bab95c7ef3ebc49fc0 Mon Sep 17 00:00:00 2001 From: Kevin Jump Date: Mon, 20 Apr 2026 19:54:12 +0100 Subject: [PATCH] remove unused parameter on download, make it an admin feature. --- .../Actions/uSyncPerformActionController.cs | 5 ++++- .../usync-assets/src/api/types.gen.ts | 4 +--- .../src/repository/SyncAction.respositoy.ts | 4 ++-- .../src/repository/sources/SyncAction.source.ts | 11 ++--------- .../usync-assets/src/workspace/workspace.context.ts | 6 +++--- 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/uSync.Backoffice.Management.Api/Controllers/Actions/uSyncPerformActionController.cs b/uSync.Backoffice.Management.Api/Controllers/Actions/uSyncPerformActionController.cs index a535a4bdd..87d519770 100644 --- a/uSync.Backoffice.Management.Api/Controllers/Actions/uSyncPerformActionController.cs +++ b/uSync.Backoffice.Management.Api/Controllers/Actions/uSyncPerformActionController.cs @@ -1,5 +1,6 @@ using Asp.Versioning; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Net.Http.Headers; @@ -9,6 +10,7 @@ using Umbraco.Cms.Core.Security; using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Web.Common.Authorization; using uSync.Backoffice.Management.Api.Models; using uSync.Backoffice.Management.Api.Services; @@ -43,7 +45,8 @@ public async Task PerformAction(PerformActionRequest mode [HttpPost("Download")] [ProducesResponseType(StatusCodes.Status200OK)] - public ActionResult Download(string requestId) + [Authorize(Policy = AuthorizationPolicies.RequireAdminAccess)] + public ActionResult Download() { var filename = "uSync.zip"; diff --git a/uSync.Backoffice.Management.Client/usync-assets/src/api/types.gen.ts b/uSync.Backoffice.Management.Client/usync-assets/src/api/types.gen.ts index 3f406cf52..acce4410c 100644 --- a/uSync.Backoffice.Management.Client/usync-assets/src/api/types.gen.ts +++ b/uSync.Backoffice.Management.Client/usync-assets/src/api/types.gen.ts @@ -1048,9 +1048,7 @@ export type GetActionsBySetResponse = GetActionsBySetResponses[keyof GetActionsB export type DownloadData = { body?: never; path?: never; - query?: { - requestId?: string; - }; + query?: never; url: '/umbraco/usync/api/v1/Download'; }; diff --git a/uSync.Backoffice.Management.Client/usync-assets/src/repository/SyncAction.respositoy.ts b/uSync.Backoffice.Management.Client/usync-assets/src/repository/SyncAction.respositoy.ts index 622142ec2..88ed9c711 100644 --- a/uSync.Backoffice.Management.Client/usync-assets/src/repository/SyncAction.respositoy.ts +++ b/uSync.Backoffice.Management.Client/usync-assets/src/repository/SyncAction.respositoy.ts @@ -127,8 +127,8 @@ export class uSyncActionRepository extends UmbControllerBase { return await this.#migrartionDataSource.copyLegacy(); } - async downloadFile(requestId: string) { - var result = await this.#actionDataSource.downloadFile(requestId); + async downloadFile() { + var result = await this.#actionDataSource.downloadFile(); console.log('Download result', result); diff --git a/uSync.Backoffice.Management.Client/usync-assets/src/repository/sources/SyncAction.source.ts b/uSync.Backoffice.Management.Client/usync-assets/src/repository/sources/SyncAction.source.ts index 33efe2a2f..1e46674f4 100644 --- a/uSync.Backoffice.Management.Client/usync-assets/src/repository/sources/SyncAction.source.ts +++ b/uSync.Backoffice.Management.Client/usync-assets/src/repository/sources/SyncAction.source.ts @@ -49,15 +49,8 @@ export class uSyncActionDataSource implements SyncActionDataSource { ); } - async downloadFile(requestId: string) { - return await tryExecute( - this.#host, - ActionsService.download({ - query: { - requestId: requestId, - }, - }), - ); + async downloadFile() { + return await tryExecute(this.#host, ActionsService.download()); } async processUpload(fileId: string) { diff --git a/uSync.Backoffice.Management.Client/usync-assets/src/workspace/workspace.context.ts b/uSync.Backoffice.Management.Client/usync-assets/src/workspace/workspace.context.ts index e87e04ea2..0eecad525 100644 --- a/uSync.Backoffice.Management.Client/usync-assets/src/workspace/workspace.context.ts +++ b/uSync.Backoffice.Management.Client/usync-assets/src/workspace/workspace.context.ts @@ -274,7 +274,7 @@ export class uSyncWorkspaceContext // post action if (options.file && options.action === 'Export') { // post export , open the dialog offer the download. - await this.downloadFile(id); + await this.downloadFile(); } if (!this.#inBackground.getValue()) { @@ -300,8 +300,8 @@ export class uSyncWorkspaceContext return true; } - async downloadFile(requestId: string) { - const response = await this.#repository.downloadFile(requestId); + async downloadFile() { + const response = await this.#repository.downloadFile(); if (!response) return;