mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-09 23:49:27 +08: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);
|
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({
|
const userRole = app.acl.define({
|
||||||
role: 'user',
|
role: 'user',
|
||||||
});
|
});
|
||||||
@ -241,9 +241,10 @@ describe('destroy action with acl', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// should throw error
|
|
||||||
expect(response.statusCode).toEqual(403);
|
expect(response.statusCode).toEqual(403);
|
||||||
|
|
||||||
|
expect(await Post.repository.count()).toBe(6);
|
||||||
|
|
||||||
const response2 = await app
|
const response2 = await app
|
||||||
.agent()
|
.agent()
|
||||||
.resource('posts')
|
.resource('posts')
|
||||||
@ -253,7 +254,6 @@ describe('destroy action with acl', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// should throw error
|
|
||||||
expect(response2.statusCode).toEqual(200);
|
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(
|
this.app.acl.use(
|
||||||
async (ctx: any, next) => {
|
async (ctx: any, next) => {
|
||||||
const action = ctx.permission?.can?.action;
|
const action = ctx.permission?.can?.action;
|
||||||
@ -546,6 +545,15 @@ export class PluginACLServer extends Plugin {
|
|||||||
return;
|
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
|
// params after merge with fixed params
|
||||||
const filteredCount = await repository.count(ctx.permission.mergedParams);
|
const filteredCount = await repository.count(ctx.permission.mergedParams);
|
||||||
|
|
||||||
@ -566,6 +574,7 @@ export class PluginACLServer extends Plugin {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
const withACLMeta = createWithACLMetaMiddleware();
|
const withACLMeta = createWithACLMetaMiddleware();
|
||||||
|
|
||||||
// append allowedActions to list & get response
|
// append allowedActions to list & get response
|
||||||
|
Loading…
x
Reference in New Issue
Block a user