Skip to content

Commit 3fd8a1d

Browse files
committed
Enable to redirect when accessing pages that is not allowed to access according to the user role
1 parent ce6ff23 commit 3fd8a1d

File tree

6 files changed

+11
-5
lines changed

6 files changed

+11
-5
lines changed

frontend/middleware/check-admin.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default function ({ store, route, redirect }) {
2+
const role = store.getters['projects/getCurrentUserRole']
3+
if (!role.is_project_admin) {
4+
redirect('/projects/' + route.params.id)
5+
}
6+
}

frontend/pages/projects/_id/dataset/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import DocumentDeletionButton from '@/components/containers/documents/DocumentDe
1616
export default {
1717
layout: 'project',
1818
19-
middleware: ['check-auth', 'auth'],
19+
middleware: ['check-auth', 'auth', 'check-admin'],
2020
2121
components: {
2222
DocumentList,

frontend/pages/projects/_id/guideline/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { mapState, mapActions } from 'vuex'
1717
export default {
1818
layout: 'project',
1919
20-
middleware: ['check-auth', 'auth'],
20+
middleware: ['check-auth', 'auth', 'check-admin'],
2121
2222
components: {
2323
Editor

frontend/pages/projects/_id/labels/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import LabelDeletionButton from '@/components/containers/labels/LabelDeletionBut
1616
export default {
1717
layout: 'project',
1818
19-
middleware: ['check-auth', 'auth'],
19+
middleware: ['check-auth', 'auth', 'check-admin'],
2020
2121
components: {
2222
LabelList,

frontend/pages/projects/_id/members/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import MemberDeletionButton from '@/components/containers/members/MemberDeletion
1616
export default {
1717
layout: 'project',
1818
19-
middleware: ['check-auth', 'auth'],
19+
middleware: ['check-auth', 'auth', 'check-admin'],
2020
2121
components: {
2222
MemberList,

frontend/pages/projects/_id/statistics/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import BarChart from '@/components/molecules/BarChart'
4141
export default {
4242
layout: 'project',
4343
44-
middleware: ['check-auth', 'auth'],
44+
middleware: ['check-auth', 'auth', 'check-admin'],
4545
4646
components: {
4747
DoughnutChart,

0 commit comments

Comments
 (0)