fix: custom request server-side permission validation error

This commit is contained in:
katherinehhh 2025-03-12 22:38:28 +08:00
parent 97940d246c
commit bcbffbc8b2

View File

@ -77,13 +77,12 @@ export async function send(this: CustomRequestPlugin, ctx: Context, next: Next)
// root role has all permissions // root role has all permissions
if (ctx.state.currentRole !== 'root') { if (ctx.state.currentRole !== 'root') {
const crRepo = ctx.db.getRepository('customRequestsRoles'); const crRepo = ctx.db.getRepository('uiButtonSchemasRoles');
const hasRoles = await crRepo.find({ const hasRoles = await crRepo.find({
filter: { filter: {
customRequestKey: filterByTk, uid: filterByTk,
}, },
}); });
if (hasRoles.length) { if (hasRoles.length) {
if (!hasRoles.find((item) => item.roleName === ctx.state.currentRole)) { if (!hasRoles.find((item) => item.roleName === ctx.state.currentRole)) {
return ctx.throw(403, 'custom request no permission'); return ctx.throw(403, 'custom request no permission');