refactor: Forbid access to workflows when enterprise features is unavailable (#4635) (no-changelog)
* refactor: Forbid access to workflows when enterprise features is unavailable
This commit is contained in:
@@ -43,13 +43,14 @@ import {
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import * as Db from '@/Db';
|
||||
import { ICredentialsDb, WhereClause } from '@/Interfaces';
|
||||
import { ICredentialsDb } from '@/Interfaces';
|
||||
import * as WorkflowExecuteAdditionalData from '@/WorkflowExecuteAdditionalData';
|
||||
import { User } from '@db/entities/User';
|
||||
import { CredentialsEntity } from '@db/entities/CredentialsEntity';
|
||||
import { NodeTypes } from '@/NodeTypes';
|
||||
import { CredentialsOverwrites } from '@/CredentialsOverwrites';
|
||||
import { CredentialTypes } from '@/CredentialTypes';
|
||||
import { whereClause } from './UserManagement/UserManagementHelper';
|
||||
|
||||
const mockNodeTypes: INodeTypes = {
|
||||
nodeTypes: {} as INodeTypeData,
|
||||
@@ -738,28 +739,6 @@ export class CredentialsHelper extends ICredentialsHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a `where` clause for a `find()` or `findOne()` operation
|
||||
* in the `shared_workflow` or `shared_credentials` tables.
|
||||
*/
|
||||
export function whereClause({
|
||||
user,
|
||||
entityType,
|
||||
entityId = '',
|
||||
}: {
|
||||
user: User;
|
||||
entityType: 'workflow' | 'credentials';
|
||||
entityId?: string;
|
||||
}): WhereClause {
|
||||
const where: WhereClause = entityId ? { [entityType]: { id: entityId } } : {};
|
||||
|
||||
if (user.globalRole.name !== 'owner') {
|
||||
where.user = { id: user.id };
|
||||
}
|
||||
|
||||
return where;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a credential if it has been shared with a user.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user