mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 08:21:53 +00:00
Merge branch 'main' into next
This commit is contained in:
commit
0564b6d674
@ -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);
|
||||
});
|
||||
});
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user