Skip to content

Commit

Permalink
Merge pull request #4513 from manuelmeister/bugfix/fix-4491--loop
Browse files Browse the repository at this point in the history
Fix schedule entry request loop if no access or typo
  • Loading branch information
manuelmeister authored Jan 20, 2024
2 parents f077e88 + c62bea9 commit 0409c5f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion frontend/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ export default new Router({
default: () => import('./views/activity/Activity.vue'),
aside: () => import('./views/activity/SideBarProgram.vue'),
},
beforeEnter: requireAuth,
beforeEnter: all([requireAuth, requireCamp, requireScheduleEntry]),
props: {
navigation: (route) => ({ camp: campFromRoute(route) }),
default: (route) => ({ scheduleEntry: scheduleEntryFromRoute(route) }),
Expand Down Expand Up @@ -450,6 +450,21 @@ async function requireCamp(to, from, next) {
})
}

async function requireScheduleEntry(to, from, next) {
await scheduleEntryFromRoute(to)
.call({ api: { get: apiStore.get } })
._meta.load.then(() => {
next()
})
.catch(() => {
next({
name: 'PageNotFound',
params: [to.fullPath, ''],
replace: true,
})
})
}

async function requirePeriod(to, from, next) {
await periodFromRoute(to)
.call({ api: { get: apiStore.get } })
Expand Down

0 comments on commit 0409c5f

Please sign in to comment.