fix(editor): Do not show project settings for users without permission with direct link (#13246)

This commit is contained in:
Csaba Tuncsik 2025-02-17 15:13:43 +01:00 committed by GitHub
parent c881ea2c7b
commit fa488f1561
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,7 @@
import type { RouteRecordRaw } from 'vue-router'; import type { RouteRecordRaw } from 'vue-router';
import { VIEWS } from '@/constants'; import { VIEWS } from '@/constants';
import { useProjectsStore } from '@/stores/projects.store';
import { getResourcePermissions } from '@/permissions';
const MainSidebar = async () => await import('@/components/MainSidebar.vue'); const MainSidebar = async () => await import('@/components/MainSidebar.vue');
const WorkflowsView = async () => await import('@/views/WorkflowsView.vue'); const WorkflowsView = async () => await import('@/views/WorkflowsView.vue');
@ -95,7 +97,15 @@ export const projectsRoutes: RouteRecordRaw[] = [
sidebar: MainSidebar, sidebar: MainSidebar,
}, },
meta: { meta: {
middleware: ['authenticated'], middleware: ['authenticated', 'custom'],
middlewareOptions: {
custom: (options) => {
const project = useProjectsStore().myProjects.find(
(p) => p.id === options?.to.params.projectId,
);
return !!getResourcePermissions(project?.scopes).project.update;
},
},
}, },
}, },
]), ]),