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'; +}