Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Asp.Versioning;

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Net.Http.Headers;
Expand All @@ -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;
Expand Down Expand Up @@ -43,7 +45,8 @@ public async Task<PerformActionResponse> PerformAction(PerformActionRequest mode

[HttpPost("Download")]
[ProducesResponseType<FileContentResult>(StatusCodes.Status200OK)]
public ActionResult Download(string requestId)
[Authorize(Policy = AuthorizationPolicies.RequireAdminAccess)]
public ActionResult Download()
{
var filename = "uSync.zip";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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;

Expand Down
Loading