mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor(core): Finish removing UserManagementHelper (no-changelog) (#8418)
This commit is contained in:
@@ -21,7 +21,7 @@ import { validateEntity } from '@/GenericHelpers';
|
||||
import { ExternalHooks } from '@/ExternalHooks';
|
||||
import { ListQuery } from '@/requests';
|
||||
import { WorkflowService } from './workflow.service';
|
||||
import { isSharingEnabled } from '@/UserManagement/UserManagementHelper';
|
||||
import { License } from '@/License';
|
||||
import { InternalHooks } from '@/InternalHooks';
|
||||
import { RoleService } from '@/services/role.service';
|
||||
import * as utils from '@/utils';
|
||||
@@ -64,6 +64,7 @@ export class WorkflowsController {
|
||||
private readonly workflowSharingService: WorkflowSharingService,
|
||||
private readonly sharedWorkflowRepository: SharedWorkflowRepository,
|
||||
private readonly userRepository: UserRepository,
|
||||
private readonly license: License,
|
||||
private readonly mailer: UserManagementMailer,
|
||||
private readonly urlService: UrlService,
|
||||
) {}
|
||||
@@ -92,7 +93,7 @@ export class WorkflowsController {
|
||||
|
||||
WorkflowHelpers.addNodeIds(newWorkflow);
|
||||
|
||||
if (isSharingEnabled()) {
|
||||
if (this.license.isSharingEnabled()) {
|
||||
// This is a new workflow, so we simply check if the user has access to
|
||||
// all used workflows
|
||||
|
||||
@@ -150,7 +151,7 @@ export class WorkflowsController {
|
||||
@Get('/', { middlewares: listQueryMiddleware })
|
||||
async getAll(req: ListQuery.Request, res: express.Response) {
|
||||
try {
|
||||
const roles: RoleNames[] = isSharingEnabled() ? [] : ['owner'];
|
||||
const roles: RoleNames[] = this.license.isSharingEnabled() ? [] : ['owner'];
|
||||
const sharedWorkflowIds = await this.workflowSharingService.getSharedWorkflowIds(
|
||||
req.user,
|
||||
roles,
|
||||
@@ -221,7 +222,7 @@ export class WorkflowsController {
|
||||
async getWorkflow(req: WorkflowRequest.Get) {
|
||||
const { id: workflowId } = req.params;
|
||||
|
||||
if (isSharingEnabled()) {
|
||||
if (this.license.isSharingEnabled()) {
|
||||
const relations = ['shared', 'shared.user', 'shared.role'];
|
||||
if (!config.getEnv('workflowTagsDisabled')) {
|
||||
relations.push('tags');
|
||||
@@ -280,7 +281,7 @@ export class WorkflowsController {
|
||||
const { tags, ...rest } = req.body;
|
||||
Object.assign(updateData, rest);
|
||||
|
||||
if (isSharingEnabled()) {
|
||||
if (this.license.isSharingEnabled()) {
|
||||
updateData = await this.enterpriseWorkflowService.preventTampering(
|
||||
updateData,
|
||||
workflowId,
|
||||
@@ -293,8 +294,8 @@ export class WorkflowsController {
|
||||
updateData,
|
||||
workflowId,
|
||||
tags,
|
||||
isSharingEnabled() ? forceSave : true,
|
||||
isSharingEnabled() ? undefined : ['owner'],
|
||||
this.license.isSharingEnabled() ? forceSave : true,
|
||||
this.license.isSharingEnabled() ? undefined : ['owner'],
|
||||
);
|
||||
|
||||
return updatedWorkflow;
|
||||
@@ -320,7 +321,7 @@ export class WorkflowsController {
|
||||
|
||||
@Post('/run')
|
||||
async runManually(req: WorkflowRequest.ManualRun) {
|
||||
if (isSharingEnabled()) {
|
||||
if (this.license.isSharingEnabled()) {
|
||||
const workflow = this.workflowRepository.create(req.body.workflowData);
|
||||
|
||||
if (req.body.workflowData.id !== undefined) {
|
||||
@@ -342,7 +343,7 @@ export class WorkflowsController {
|
||||
|
||||
@Put('/:workflowId/share')
|
||||
async share(req: WorkflowRequest.Share) {
|
||||
if (!isSharingEnabled()) throw new NotFoundError('Route not found');
|
||||
if (!this.license.isSharingEnabled()) throw new NotFoundError('Route not found');
|
||||
|
||||
const { workflowId } = req.params;
|
||||
const { shareWithIds } = req.body;
|
||||
|
||||
Reference in New Issue
Block a user