Merge branch 'main' into next

This commit is contained in:
nocobase[bot] 2024-10-26 02:56:30 +00:00
commit 0564b6d674
2 changed files with 13 additions and 4 deletions

View File

@ -184,7 +184,7 @@ describe('destroy action with acl', () => {
expect(response.statusCode).toEqual(403);
});
it('should throw error when user has no permissions with array query', async () => {
it.skip('should throw error when user has no permissions with array query', async () => {
const userRole = app.acl.define({
role: 'user',
});
@ -241,9 +241,10 @@ describe('destroy action with acl', () => {
},
});
// should throw error
expect(response.statusCode).toEqual(403);
expect(await Post.repository.count()).toBe(6);
const response2 = await app
.agent()
.resource('posts')
@ -253,7 +254,6 @@ describe('destroy action with acl', () => {
},
});
// should throw error
expect(response2.statusCode).toEqual(200);
});
});

View File

@ -533,7 +533,6 @@ export class PluginACLServer extends Plugin {
}
});
// throw error when user has no fixed params permissions
this.app.acl.use(
async (ctx: any, next) => {
const action = ctx.permission?.can?.action;
@ -546,6 +545,15 @@ export class PluginACLServer extends Plugin {
return;
}
const hasFilterByTk = (params) => {
return JSON.stringify(params).includes('filterByTk');
}
if (!hasFilterByTk(ctx.permission.mergedParams) || !hasFilterByTk(ctx.permission.rawParams)) {
await next();
return;
}
// params after merge with fixed params
const filteredCount = await repository.count(ctx.permission.mergedParams);
@ -566,6 +574,7 @@ export class PluginACLServer extends Plugin {
},
);
const withACLMeta = createWithACLMetaMiddleware();
// append allowedActions to list & get response