mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
fix: Change the currentUserHasAccess flag behavior (no-changelog) (#4763)
This commit is contained in:
parent
92c77127d6
commit
47b9d22ed5
|
@ -33,7 +33,7 @@ export class CredentialsService {
|
|||
|
||||
static async getAll(
|
||||
user: User,
|
||||
options?: { relations?: string[]; roles?: string[] },
|
||||
options?: { relations?: string[]; roles?: string[]; disableGlobalRole?: boolean },
|
||||
): Promise<ICredentialsDb[]> {
|
||||
const SELECT_FIELDS: Array<keyof ICredentialsDb> = [
|
||||
'id',
|
||||
|
@ -46,7 +46,7 @@ export class CredentialsService {
|
|||
|
||||
// if instance owner, return all credentials
|
||||
|
||||
if (user.globalRole.name === 'owner') {
|
||||
if (user.globalRole.name === 'owner' && options?.disableGlobalRole !== true) {
|
||||
return Db.collections.Credentials.find({
|
||||
select: SELECT_FIELDS,
|
||||
relations: options?.relations,
|
||||
|
|
|
@ -109,7 +109,7 @@ export class EEWorkflowsService extends WorkflowsService {
|
|||
currentUser: User,
|
||||
): Promise<void> {
|
||||
workflow.usedCredentials = [];
|
||||
const userCredentials = await EECredentials.getAll(currentUser);
|
||||
const userCredentials = await EECredentials.getAll(currentUser, { disableGlobalRole: true });
|
||||
const credentialIdsUsedByWorkflow = new Set<number>();
|
||||
workflow.nodes.forEach((node) => {
|
||||
if (!node.credentials) {
|
||||
|
|
|
@ -333,7 +333,7 @@ describe('GET /workflows/:id', () => {
|
|||
expect(response.body.data.sharedWith).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('GET should return workflow with credentials saying owner has access even when not shared', async () => {
|
||||
test('GET should return workflow with credentials saying owner does not have access when not shared', async () => {
|
||||
const owner = await testDb.createUser({ globalRole: globalOwnerRole });
|
||||
const member = await testDb.createUser({ globalRole: globalMemberRole });
|
||||
const savedCredential = await saveCredential(randomCredentialPayload(), { user: member });
|
||||
|
@ -351,7 +351,7 @@ describe('GET /workflows/:id', () => {
|
|||
{
|
||||
id: savedCredential.id.toString(),
|
||||
name: savedCredential.name,
|
||||
currentUserHasAccess: true, // owner has access to any cred
|
||||
currentUserHasAccess: false, // although owner can see, he does not have access
|
||||
},
|
||||
]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue