Skip to content

Commit

Permalink
permission to check if user can create a project for a subject
Browse files Browse the repository at this point in the history
  • Loading branch information
reyniersbram committed May 3, 2024
1 parent f59fc16 commit d717c72
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions frontend/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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)),
},
},
{
Expand Down

0 comments on commit d717c72

Please sign in to comment.