Fix `ignoreGuardsForHomeRoute` workaround...
This commit is contained in:
parent
9a3af24f72
commit
7847191d97
|
|
@ -60,7 +60,7 @@ const selectedCourseSessionTitle = computed(() => {
|
|||
const appointmentsUrl = computed(() => {
|
||||
const currentCourseSession = courseSessionsStore.currentCourseSession;
|
||||
if (currentCourseSession) {
|
||||
return `/course/${currentCourseSession.course.slug}/appointments`;
|
||||
return `/course/dashboard/due-dates`;
|
||||
} else {
|
||||
return `/appointments`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,10 @@ const loginRequired = (to: RouteLocationNormalized) => {
|
|||
return !to.meta?.public;
|
||||
};
|
||||
|
||||
export async function handleCurrentCourseSession(to: RouteLocationNormalized) {
|
||||
export async function handleCurrentCourseSession(
|
||||
to: RouteLocationNormalized,
|
||||
options?: { unset?: boolean }
|
||||
) {
|
||||
// register after login hooks
|
||||
const userStore = useUserStore();
|
||||
if (userStore.loggedIn) {
|
||||
|
|
@ -59,7 +62,9 @@ export async function handleCurrentCourseSession(to: RouteLocationNormalized) {
|
|||
if (to.params.courseSlug) {
|
||||
courseSessionsStore._currentCourseSlug = to.params.courseSlug as string;
|
||||
} else {
|
||||
courseSessionsStore._currentCourseSlug = "";
|
||||
if (options?.unset) {
|
||||
courseSessionsStore._currentCourseSlug = "";
|
||||
}
|
||||
}
|
||||
if (!courseSessionsStore.loaded) {
|
||||
console.log("handleCurrentCourseSession: loadCourseSessionsData");
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import {
|
|||
} from "@/router/guards";
|
||||
import { addToHistory } from "@/router/history";
|
||||
import { onboardingRedirect } from "@/router/onboarding";
|
||||
import type { RouteLocationNormalized } from "vue-router";
|
||||
import { createRouter, createWebHistory } from "vue-router";
|
||||
|
||||
const router = createRouter({
|
||||
|
|
@ -396,26 +395,14 @@ router.beforeEach(updateLoggedIn);
|
|||
router.beforeEach(redirectToLoginIfRequired);
|
||||
|
||||
// register after login hooks
|
||||
router.beforeEach(
|
||||
async (to, from) =>
|
||||
await ignoreGuardsForHomeRoute(to, from, handleCurrentCourseSession)
|
||||
);
|
||||
router.beforeEach(async (to, from) => await handleCurrentCourseSession(to));
|
||||
router.beforeEach(async (to, from) => await handleCourseSessionAsQueryParam(to));
|
||||
|
||||
router.beforeEach(
|
||||
async (to, from) =>
|
||||
await ignoreGuardsForHomeRoute(to, from, handleCourseSessionAsQueryParam)
|
||||
// only unset the current course session in the after hook
|
||||
router.afterEach(
|
||||
async (to, from) => await handleCurrentCourseSession(to, { unset: true })
|
||||
);
|
||||
|
||||
async function ignoreGuardsForHomeRoute(
|
||||
to: RouteLocationNormalized,
|
||||
from: RouteLocationNormalized,
|
||||
guard: any
|
||||
) {
|
||||
if (to.name !== "home") {
|
||||
return await guard(to);
|
||||
}
|
||||
}
|
||||
|
||||
router.beforeEach(addToHistory);
|
||||
|
||||
export default router;
|
||||
|
|
|
|||
|
|
@ -41,10 +41,10 @@ from vbv_lernwelt.course.views import (
|
|||
from vbv_lernwelt.course_session.views import get_course_session_documents
|
||||
from vbv_lernwelt.dashboard.views import (
|
||||
get_dashboard_config,
|
||||
get_dashboard_due_dates,
|
||||
get_dashboard_persons,
|
||||
get_mentee_count,
|
||||
get_mentor_open_tasks_count,
|
||||
get_dashboard_due_dates,
|
||||
)
|
||||
from vbv_lernwelt.edoniq_test.views import (
|
||||
export_students,
|
||||
|
|
|
|||
Loading…
Reference in New Issue