diff --git a/frontend/layouts/project.vue b/frontend/layouts/project.vue index a0580276..a0be4840 100644 --- a/frontend/layouts/project.vue +++ b/frontend/layouts/project.vue @@ -41,6 +41,8 @@ import TheSideBar from '~/components/organisms/layout/TheSideBar' import TheHeader from '~/components/organisms/layout/TheHeader' export default { + middleware: ['check-auth', 'auth', 'check-admin'], + components: { TheSideBar, TheHeader diff --git a/frontend/middleware/check-admin.js b/frontend/middleware/check-admin.js index 6b14eb2a..95d4c31d 100644 --- a/frontend/middleware/check-admin.js +++ b/frontend/middleware/check-admin.js @@ -1,6 +1,8 @@ export default function ({ store, route, redirect }) { const role = store.getters['projects/getCurrentUserRole'] - if (!role.is_project_admin) { - redirect('/projects/' + route.params.id) + const projectRoot = '/projects/' + route.params.id + const path = route.fullPath.replace(/\/$/g, '') + if (!role.is_project_admin && path !== projectRoot) { + return redirect(projectRoot) } } diff --git a/frontend/pages/projects/_id/dataset/index.vue b/frontend/pages/projects/_id/dataset/index.vue index 3cd2c416..009923d9 100644 --- a/frontend/pages/projects/_id/dataset/index.vue +++ b/frontend/pages/projects/_id/dataset/index.vue @@ -16,8 +16,6 @@ import DocumentDeletionButton from '@/components/containers/documents/DocumentDe export default { layout: 'project', - middleware: ['check-auth', 'auth', 'check-admin'], - components: { DocumentList, DocumentActionMenu, diff --git a/frontend/pages/projects/_id/guideline/index.vue b/frontend/pages/projects/_id/guideline/index.vue index f51f2f0e..95e666bb 100644 --- a/frontend/pages/projects/_id/guideline/index.vue +++ b/frontend/pages/projects/_id/guideline/index.vue @@ -17,8 +17,6 @@ import { mapState, mapActions } from 'vuex' export default { layout: 'project', - middleware: ['check-auth', 'auth', 'check-admin'], - components: { Editor }, diff --git a/frontend/pages/projects/_id/index.vue b/frontend/pages/projects/_id/index.vue index ee21302c..fd67a32b 100644 --- a/frontend/pages/projects/_id/index.vue +++ b/frontend/pages/projects/_id/index.vue @@ -54,8 +54,6 @@ export default { layout: 'project', - middleware: ['check-auth', 'auth'], - data() { return { e6: 1, diff --git a/frontend/pages/projects/_id/labels/index.vue b/frontend/pages/projects/_id/labels/index.vue index 72c251e4..8a8886de 100644 --- a/frontend/pages/projects/_id/labels/index.vue +++ b/frontend/pages/projects/_id/labels/index.vue @@ -16,8 +16,6 @@ import LabelDeletionButton from '@/components/containers/labels/LabelDeletionBut export default { layout: 'project', - middleware: ['check-auth', 'auth', 'check-admin'], - components: { LabelList, LabelActionMenu, diff --git a/frontend/pages/projects/_id/members/index.vue b/frontend/pages/projects/_id/members/index.vue index 2170dd7a..d1931afa 100644 --- a/frontend/pages/projects/_id/members/index.vue +++ b/frontend/pages/projects/_id/members/index.vue @@ -16,8 +16,6 @@ import MemberDeletionButton from '@/components/containers/members/MemberDeletion export default { layout: 'project', - middleware: ['check-auth', 'auth', 'check-admin'], - components: { MemberList, MemberAdditionButton, diff --git a/frontend/pages/projects/_id/statistics/index.vue b/frontend/pages/projects/_id/statistics/index.vue index 966e92a0..eb618ffd 100644 --- a/frontend/pages/projects/_id/statistics/index.vue +++ b/frontend/pages/projects/_id/statistics/index.vue @@ -41,8 +41,6 @@ import BarChart from '@/components/molecules/BarChart' export default { layout: 'project', - middleware: ['check-auth', 'auth', 'check-admin'], - components: { DoughnutChart, BarChart