fix: Change the currentUserHasAccess flag behavior (no-changelog) (#4763)

This commit is contained in:
Omar Ajoue 2022-11-29 15:54:24 +01:00 committed by GitHub
parent 92c77127d6
commit 47b9d22ed5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View file

@ -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,

View file

@ -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) {

View file

@ -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
},
]);