Files
n8n-enterprise-unlocked/packages/editor-ui/src/rbac/middleware/custom.ts
Alex Grozav 67a88914f2 feat(editor): Add routing middleware, permission checks, RBAC store, RBAC component (#7702)
Github issue / Community forum post (link here to close automatically):

---------

Co-authored-by: Csaba Tuncsik <csaba@n8n.io>
2023-11-23 13:22:47 +02:00

15 lines
344 B
TypeScript

import type { CustomMiddlewareOptions, RouterMiddleware } from '@/types/router';
import { VIEWS } from '@/constants';
export const customMiddleware: RouterMiddleware<CustomMiddlewareOptions> = async (
to,
from,
next,
isValid,
) => {
const valid = isValid({ to, from, next });
if (!valid) {
return next({ name: VIEWS.HOMEPAGE });
}
};