mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
Github issue / Community forum post (link here to close automatically): --------- Co-authored-by: Csaba Tuncsik <csaba@n8n.io>
17 lines
410 B
TypeScript
17 lines
410 B
TypeScript
import type { RouterMiddleware } from '@/types/router';
|
|
import type { RolePermissionOptions } from '@/types/rbac';
|
|
import { VIEWS } from '@/constants';
|
|
import { hasRole } from '@/rbac/checks';
|
|
|
|
export const roleMiddleware: RouterMiddleware<RolePermissionOptions> = async (
|
|
to,
|
|
from,
|
|
next,
|
|
checkRoles,
|
|
) => {
|
|
const valid = hasRole(checkRoles);
|
|
if (!valid) {
|
|
return next({ name: VIEWS.HOMEPAGE });
|
|
}
|
|
};
|