From c853106f5454a7401bee660a324d64e7f73d9671 Mon Sep 17 00:00:00 2001 From: bsilkyn Date: Sat, 20 Apr 2024 09:08:17 +0200 Subject: [PATCH] chore: add admin guard file that I forgot to add #199 --- frontend/src/router/guards/admin.guard.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 frontend/src/router/guards/admin.guard.ts diff --git a/frontend/src/router/guards/admin.guard.ts b/frontend/src/router/guards/admin.guard.ts new file mode 100644 index 00000000..f392b404 --- /dev/null +++ b/frontend/src/router/guards/admin.guard.ts @@ -0,0 +1,10 @@ +import { useAuthStore } from '@/store/authentication.store.ts'; +import { type RouteLocationRaw } from 'vue-router'; + +export function AdminGuard(): boolean | RouteLocationRaw { + const { user } = useAuthStore(); + if (user?.is_staff ?? false) { + return true; + } + return 'dashboard'; +}