From 32b7e35a1a1bf98ee261a8b8e7c2864a197b937e Mon Sep 17 00:00:00 2001 From: lesion Date: Fri, 9 Feb 2024 22:33:27 +0100 Subject: [PATCH] admin panel for editor --- components/NavHeader.vue | 4 ++-- middleware/isAdminOrEditor.js | 5 +++++ pages/Admin.vue | 32 +++++++++++++++++--------------- pages/event/_slug.vue | 6 +++--- server/api/controller/event.js | 6 +++--- server/api/index.js | 10 +++++----- 6 files changed, 35 insertions(+), 28 deletions(-) create mode 100644 middleware/isAdminOrEditor.js diff --git a/components/NavHeader.vue b/components/NavHeader.vue index 02067c39..d72b1c2b 100644 --- a/components/NavHeader.vue +++ b/components/NavHeader.vue @@ -49,12 +49,12 @@ - + - + diff --git a/middleware/isAdminOrEditor.js b/middleware/isAdminOrEditor.js new file mode 100644 index 00000000..63b359c9 --- /dev/null +++ b/middleware/isAdminOrEditor.js @@ -0,0 +1,5 @@ +export default async function ({ redirect, $auth }) { + if (!$auth.user.is_editor && !$auth.user.is_admin) { + return redirect('/') + } +} \ No newline at end of file diff --git a/pages/Admin.vue b/pages/Admin.vue index 06d15bba..795e4a61 100644 --- a/pages/Admin.vue +++ b/pages/Admin.vue @@ -1,14 +1,16 @@