fix(editor): Replace isInstanceOwner checks with scopes where applicable (#7858)

Co-authored-by: Alex Grozav <alex@grozav.com>
This commit is contained in:
Csaba Tuncsik
2023-12-04 10:02:54 +01:00
committed by GitHub
parent 39fa8d21bb
commit 132d691cbf
21 changed files with 111 additions and 67 deletions

View File

@@ -38,12 +38,13 @@ import { isObject } from '@/utils/objectUtils';
import { getCredentialPermissions } from '@/permissions';
import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/settings.store';
import { useUsersStore } from '@/stores/users.store';
import { hasPermission } from '@/rbac/permissions';
import { useWorkflowsStore } from '@/stores/workflows.store';
import { useRootStore } from '@/stores/n8nRoot.store';
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
import { useCredentialsStore } from '@/stores/credentials.store';
import { defineComponent } from 'vue';
import { useUsersStore } from '@/stores/users.store';
export const nodeHelpers = defineComponent({
computed: {
@@ -53,7 +54,6 @@ export const nodeHelpers = defineComponent({
useNodeTypesStore,
useSettingsStore,
useWorkflowsStore,
useUsersStore,
useRootStore,
),
},
@@ -475,11 +475,13 @@ export const nodeHelpers = defineComponent({
}
if (nameMatches.length === 0) {
const isInstanceOwner = this.usersStore.isInstanceOwner;
const isCredentialUsedInWorkflow =
this.workflowsStore.usedCredentials?.[selectedCredentials.id as string];
if (!isCredentialUsedInWorkflow && !isInstanceOwner) {
if (
!isCredentialUsedInWorkflow &&
!hasPermission(['rbac'], { rbac: { scope: 'credential:read' } })
) {
foundIssues[credentialTypeDescription.name] = [
this.$locale.baseText('nodeIssues.credentials.doNotExist', {
interpolate: { name: selectedCredentials.name, type: credentialDisplayName },