fix: custom request server-side permission validation error (#6438)

This commit is contained in:
Katherine 2025-03-12 22:44:10 +08:00 committed by GitHub
parent 97940d246c
commit c408c916d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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');