From c219ce975263ffe000449c9fe253a656ee2ef76a Mon Sep 17 00:00:00 2001 From: Hironsan Date: Thu, 8 Jun 2023 21:14:22 +0900 Subject: [PATCH] Move middleware from layout to page --- frontend/layouts/project.vue | 2 -- frontend/pages/projects/_id/comments/index.vue | 2 +- frontend/pages/projects/_id/dataset/_example_id/edit.vue | 2 +- frontend/pages/projects/_id/dataset/export.vue | 2 +- frontend/pages/projects/_id/dataset/import.vue | 2 +- frontend/pages/projects/_id/dataset/index.vue | 2 ++ frontend/pages/projects/_id/guideline/index.vue | 2 +- frontend/pages/projects/_id/index.vue | 2 ++ frontend/pages/projects/_id/labels/_label_id/edit.vue | 2 +- frontend/pages/projects/_id/labels/add.vue | 2 ++ frontend/pages/projects/_id/labels/import.vue | 2 +- frontend/pages/projects/_id/labels/index.vue | 2 ++ frontend/pages/projects/_id/members/index.vue | 2 +- frontend/pages/projects/_id/metrics/index.vue | 2 +- frontend/pages/projects/_id/settings/index.vue | 2 +- 15 files changed, 18 insertions(+), 12 deletions(-) diff --git a/frontend/layouts/project.vue b/frontend/layouts/project.vue index 2642eb12..35615c93 100644 --- a/frontend/layouts/project.vue +++ b/frontend/layouts/project.vue @@ -33,8 +33,6 @@ export default { TheHeader }, - middleware: ['check-auth', 'auth', 'setCurrentProject'], - data() { return { drawerLeft: null, diff --git a/frontend/pages/projects/_id/comments/index.vue b/frontend/pages/projects/_id/comments/index.vue index 9fe2434a..89225e6e 100644 --- a/frontend/pages/projects/_id/comments/index.vue +++ b/frontend/pages/projects/_id/comments/index.vue @@ -42,7 +42,7 @@ export default Vue.extend({ layout: 'project', - middleware: ['isProjectAdmin'], + middleware: ['check-auth', 'auth', 'setCurrentProject', 'isProjectAdmin'], validate({ params }) { return /^\d+$/.test(params.id) diff --git a/frontend/pages/projects/_id/dataset/_example_id/edit.vue b/frontend/pages/projects/_id/dataset/_example_id/edit.vue index 79094ed8..9119fa46 100644 --- a/frontend/pages/projects/_id/dataset/_example_id/edit.vue +++ b/frontend/pages/projects/_id/dataset/_example_id/edit.vue @@ -27,7 +27,7 @@ import { ExampleDTO } from '~/services/application/example/exampleData' export default Vue.extend({ layout: 'project', - middleware: ['isProjectAdmin'], + middleware: ['check-auth', 'auth', 'setCurrentProject', 'isProjectAdmin'], validate({ params, app }) { if (/^\d+$/.test(params.id) && /^\d+$/.test(params.example_id)) { diff --git a/frontend/pages/projects/_id/dataset/export.vue b/frontend/pages/projects/_id/dataset/export.vue index 2c113292..3cd95c30 100644 --- a/frontend/pages/projects/_id/dataset/export.vue +++ b/frontend/pages/projects/_id/dataset/export.vue @@ -44,7 +44,7 @@ import { Format } from '~/domain/models/download/format' export default Vue.extend({ layout: 'project', - middleware: ['isProjectAdmin'], + middleware: ['check-auth', 'auth', 'setCurrentProject', 'isProjectAdmin'], validate({ params }) { return /^\d+$/.test(params.id) diff --git a/frontend/pages/projects/_id/dataset/import.vue b/frontend/pages/projects/_id/dataset/import.vue index 3e39d452..74e8bbc7 100644 --- a/frontend/pages/projects/_id/dataset/import.vue +++ b/frontend/pages/projects/_id/dataset/import.vue @@ -105,7 +105,7 @@ export default { layout: 'project', - middleware: ['isProjectAdmin'], + middleware: ['check-auth', 'auth', 'setCurrentProject', 'isProjectAdmin'], validate({ params }) { return /^\d+$/.test(params.id) diff --git a/frontend/pages/projects/_id/dataset/index.vue b/frontend/pages/projects/_id/dataset/index.vue index bb890c75..37c4cf47 100644 --- a/frontend/pages/projects/_id/dataset/index.vue +++ b/frontend/pages/projects/_id/dataset/index.vue @@ -90,6 +90,8 @@ export default Vue.extend({ layout: 'project', + middleware: ['check-auth', 'auth', 'setCurrentProject'], + validate({ params, query }) { // @ts-ignore return /^\d+$/.test(params.id) && /^\d+|$/.test(query.limit) && /^\d+|$/.test(query.offset) diff --git a/frontend/pages/projects/_id/guideline/index.vue b/frontend/pages/projects/_id/guideline/index.vue index 23fcfba8..d8ca7dcd 100644 --- a/frontend/pages/projects/_id/guideline/index.vue +++ b/frontend/pages/projects/_id/guideline/index.vue @@ -24,7 +24,7 @@ export default { layout: 'project', - middleware: ['isProjectAdmin'], + middleware: ['check-auth', 'auth', 'setCurrentProject', 'isProjectAdmin'], validate({ params }) { return /^\d+$/.test(params.id) diff --git a/frontend/pages/projects/_id/index.vue b/frontend/pages/projects/_id/index.vue index 10498869..9dfbcc3b 100644 --- a/frontend/pages/projects/_id/index.vue +++ b/frontend/pages/projects/_id/index.vue @@ -28,6 +28,8 @@ export default { layout: 'project', + middleware: ['check-auth', 'auth', 'setCurrentProject'], + validate({ params }) { return /^\d+$/.test(params.id) }, diff --git a/frontend/pages/projects/_id/labels/_label_id/edit.vue b/frontend/pages/projects/_id/labels/_label_id/edit.vue index f833cf5d..abc01d34 100644 --- a/frontend/pages/projects/_id/labels/_label_id/edit.vue +++ b/frontend/pages/projects/_id/labels/_label_id/edit.vue @@ -19,7 +19,7 @@ export default Vue.extend({ layout: 'project', - middleware: ['isProjectAdmin'], + middleware: ['check-auth', 'auth', 'setCurrentProject', 'isProjectAdmin'], validate({ params, query, app }) { if (!['category', 'span', 'relation'].includes(query.type as string)) { diff --git a/frontend/pages/projects/_id/labels/add.vue b/frontend/pages/projects/_id/labels/add.vue index db6bd4f4..03dfbd4c 100644 --- a/frontend/pages/projects/_id/labels/add.vue +++ b/frontend/pages/projects/_id/labels/add.vue @@ -29,6 +29,8 @@ export default Vue.extend({ layout: 'project', + middleware: ['check-auth', 'auth', 'setCurrentProject'], + validate({ params, query, app }) { if (!['category', 'span', 'relation'].includes(query.type as string)) { return false diff --git a/frontend/pages/projects/_id/labels/import.vue b/frontend/pages/projects/_id/labels/import.vue index 22cd8df9..ab7ebedb 100644 --- a/frontend/pages/projects/_id/labels/import.vue +++ b/frontend/pages/projects/_id/labels/import.vue @@ -14,7 +14,7 @@ export default Vue.extend({ layout: 'project', - middleware: ['isProjectAdmin'], + middleware: ['check-auth', 'auth', 'setCurrentProject', 'isProjectAdmin'], validate({ params, query, app }) { if (!['category', 'span', 'relation'].includes(query.type as string)) { diff --git a/frontend/pages/projects/_id/labels/index.vue b/frontend/pages/projects/_id/labels/index.vue index 2cb6a538..8e34b012 100644 --- a/frontend/pages/projects/_id/labels/index.vue +++ b/frontend/pages/projects/_id/labels/index.vue @@ -58,6 +58,8 @@ export default Vue.extend({ layout: 'project', + middleware: ['check-auth', 'auth', 'setCurrentProject'], + validate({ params, app }) { if (/^\d+$/.test(params.id)) { return app.$services.project.findById(params.id).then((project: Project) => { diff --git a/frontend/pages/projects/_id/members/index.vue b/frontend/pages/projects/_id/members/index.vue index a957781b..27621396 100644 --- a/frontend/pages/projects/_id/members/index.vue +++ b/frontend/pages/projects/_id/members/index.vue @@ -44,7 +44,7 @@ export default Vue.extend({ layout: 'project', - middleware: ['isProjectAdmin'], + middleware: ['check-auth', 'auth', 'setCurrentProject', 'isProjectAdmin'], validate({ params }) { return /^\d+$/.test(params.id) diff --git a/frontend/pages/projects/_id/metrics/index.vue b/frontend/pages/projects/_id/metrics/index.vue index 98c45aa8..3b14cf76 100644 --- a/frontend/pages/projects/_id/metrics/index.vue +++ b/frontend/pages/projects/_id/metrics/index.vue @@ -39,7 +39,7 @@ export default { layout: 'project', - middleware: ['isProjectAdmin'], + middleware: ['check-auth', 'auth', 'setCurrentProject', 'isProjectAdmin'], validate({ params }) { return /^\d+$/.test(params.id) diff --git a/frontend/pages/projects/_id/settings/index.vue b/frontend/pages/projects/_id/settings/index.vue index 017d5bb8..e65b5100 100644 --- a/frontend/pages/projects/_id/settings/index.vue +++ b/frontend/pages/projects/_id/settings/index.vue @@ -31,7 +31,7 @@ export default Vue.extend({ layout: 'project', - middleware: ['isProjectAdmin'], + middleware: ['check-auth', 'auth', 'setCurrentProject', 'isProjectAdmin'], validate({ params }) { return /^\d+$/.test(params.id)