tachybase_todo/packages/core/acl/src/skip-middleware.ts

17 lines
407 B
TypeScript
Raw Normal View History

2022-02-11 23:59:03 +08:00
export const skip = (options: ACLSkipOptions) => {
return async function ACLSkipMiddleware(ctx, next) {
const { resourceName, actionName } = ctx.action;
if (resourceName === options.resourceName && actionName === options.actionName) {
ctx.permission = {
skip: true,
};
}
await next();
};
};
interface ACLSkipOptions {
resourceName: string;
actionName: string;
}