From d717c72b74ec474ce177ad2b6cd864bb4c8e6063 Mon Sep 17 00:00:00 2001 From: Bram Reyniers Date: Fri, 3 May 2024 11:31:27 +0200 Subject: [PATCH] permission to check if user can create a project for a subject --- frontend/src/router/index.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 7d8141eb..4f783c6d 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -2,8 +2,7 @@ import { createRouter, createWebHistory } from "vue-router"; import { type Middleware, type MiddlewareContext, nextFactory } from "./middleware/index"; import isAuthenticated from "./middleware/isAuthenticated"; import loginMiddleware from "./middleware/login"; -import useCanVisit, { useIsAdminCondition, useIsPartOfSubjectCondition } from "./middleware/canVisit"; -import useIsTeacher from "@/composables/useIsTeacher"; +import useCanVisit, { useIsAdminCondition, useIsTeacherCondition, useIsPartOfSubjectCondition, useAndCondition } from "./middleware/canVisit"; import { ref } from "vue"; declare module "vue-router" { @@ -94,11 +93,7 @@ const router = createRouter({ component: () => import("../views/CreateProjectView.vue"), props: (route) => ({ subjectId: Number(route.params.subjectId) }), meta: { - middleware: useCanVisit((queryClient) => { - // TODO: check if user is teacher or instructor of subject - const { isTeacher, isLoading } = useIsTeacher(queryClient); - return { condition: isTeacher, isLoading }; - }), + middleware: useCanVisit(useAndCondition(useIsPartOfSubjectCondition, useIsTeacherCondition)), }, }, {