mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
fix(editor): Optionally share credentials used by the workflow when moving the workflow between projects (#12524)
Co-authored-by: Danny Martini <danny@n8n.io>
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import { ImportWorkflowFromUrlDto, ManualRunQueryDto } from '@n8n/api-types';
|
||||
import {
|
||||
ImportWorkflowFromUrlDto,
|
||||
ManualRunQueryDto,
|
||||
TransferWorkflowBodyDto,
|
||||
} from '@n8n/api-types';
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import
|
||||
import { In, type FindOptionsRelations } from '@n8n/typeorm';
|
||||
@@ -7,7 +11,6 @@ import express from 'express';
|
||||
import { Logger } from 'n8n-core';
|
||||
import { ApplicationError } from 'n8n-workflow';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { z } from 'zod';
|
||||
|
||||
import type { Project } from '@/databases/entities/project';
|
||||
import { SharedWorkflow } from '@/databases/entities/shared-workflow';
|
||||
@@ -18,7 +21,19 @@ import { SharedWorkflowRepository } from '@/databases/repositories/shared-workfl
|
||||
import { TagRepository } from '@/databases/repositories/tag.repository';
|
||||
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
|
||||
import * as Db from '@/db';
|
||||
import { Delete, Get, Patch, Post, ProjectScope, Put, Query, RestController } from '@/decorators';
|
||||
import {
|
||||
Body,
|
||||
Delete,
|
||||
Get,
|
||||
Licensed,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
ProjectScope,
|
||||
Put,
|
||||
Query,
|
||||
RestController,
|
||||
} from '@/decorators';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
import { ForbiddenError } from '@/errors/response-errors/forbidden.error';
|
||||
import { InternalServerError } from '@/errors/response-errors/internal-server.error';
|
||||
@@ -402,11 +417,10 @@ export class WorkflowsController {
|
||||
);
|
||||
}
|
||||
|
||||
@Licensed('feat:sharing')
|
||||
@Put('/:workflowId/share')
|
||||
@ProjectScope('workflow:share')
|
||||
async share(req: WorkflowRequest.Share) {
|
||||
if (!this.license.isSharingEnabled()) throw new NotFoundError('Route not found');
|
||||
|
||||
const { workflowId } = req.params;
|
||||
const { shareWithIds } = req.body;
|
||||
|
||||
@@ -472,13 +486,17 @@ export class WorkflowsController {
|
||||
|
||||
@Put('/:workflowId/transfer')
|
||||
@ProjectScope('workflow:move')
|
||||
async transfer(req: WorkflowRequest.Transfer) {
|
||||
const body = z.object({ destinationProjectId: z.string() }).parse(req.body);
|
||||
|
||||
async transfer(
|
||||
req: AuthenticatedRequest,
|
||||
_res: unknown,
|
||||
@Param('workflowId') workflowId: string,
|
||||
@Body body: TransferWorkflowBodyDto,
|
||||
) {
|
||||
return await this.enterpriseWorkflowService.transferOne(
|
||||
req.user,
|
||||
req.params.workflowId,
|
||||
workflowId,
|
||||
body.destinationProjectId,
|
||||
body.shareCredentials,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user