mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
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>
This commit is contained in:
16
packages/editor-ui/src/rbac/middleware/guest.ts
Normal file
16
packages/editor-ui/src/rbac/middleware/guest.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { RouterMiddleware } from '@/types/router';
|
||||
import { VIEWS } from '@/constants';
|
||||
import type { GuestPermissionOptions } from '@/types/rbac';
|
||||
import { isGuest } from '@/rbac/checks';
|
||||
|
||||
export const guestMiddleware: RouterMiddleware<GuestPermissionOptions> = async (to, from, next) => {
|
||||
const valid = isGuest();
|
||||
if (!valid) {
|
||||
const redirect = to.query.redirect as string;
|
||||
if (redirect && redirect.startsWith('/')) {
|
||||
return next(redirect);
|
||||
}
|
||||
|
||||
return next({ name: VIEWS.HOMEPAGE });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user