Skip to content
This repository was archived by the owner on Dec 8, 2022. It is now read-only.

Commit e7e9389

Browse files
Merge pull request #220 from codewizardshq/add-test-route
add /testing/vote route, logic to bypass nav guards and redirects
2 parents 60750c1 + 9dbfcf8 commit e7e9389

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

src/plugins/router.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,29 @@ async function logout() {
2323
}
2424

2525
const routes = [
26+
// testing route
27+
{
28+
path: "/testing",
29+
component: () => import("@/views/Voting/App"),
30+
children: [
31+
{
32+
path: "vote",
33+
name: "vote",
34+
component: () => import("@/views/Voting/Ballot")
35+
}
36+
]
37+
},
2638
{
2739
// basically a dynamic home page
2840
path: "/",
2941
name: "redirect",
3042
beforeEnter(to, from, next) {
43+
// for testing
44+
if (to.path === "/testing/vote") {
45+
console.log("in redirect", to.path);
46+
next({ path: "/testing/vote" });
47+
return;
48+
}
3149
if (isChallengeOpen() || isChallengePending()) {
3250
next({ name: "quiz" });
3351
return;
@@ -226,6 +244,13 @@ const router = new VueRouter({
226244
});
227245

228246
router.beforeEach(async (to, from, next) => {
247+
// for testing
248+
if (to.path === "/testing/vote") {
249+
console.log("bypassing beforeEach");
250+
next();
251+
return;
252+
}
253+
229254
const requireAuth = to.matched.some(record => record.meta.secured);
230255
const requireAnon = to.matched.some(record => record.meta.anon);
231256
const requireChallengePending = to.matched.some(

src/views/Voting/Ballot.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ export default {
213213
this.pageData.page = 1;
214214
await this.search();
215215
} else {
216-
this.$router.push({ name: "redirect" });
216+
// for testing
217+
if (this.$router.history._startLocation !== "/testing/vote") {
218+
this.$router.push({ name: "redirect" });
219+
}
217220
}
218221
}
219222
this.requestCount--;
@@ -228,7 +231,10 @@ export default {
228231
this.pageData.page = 1;
229232
await this.loadPage();
230233
} else {
231-
this.$router.push({ name: "redirect" });
234+
// for testing
235+
if (this.$router.history._startLocation !== "/testing/vote") {
236+
this.$router.push({ name: "redirect" });
237+
}
232238
}
233239
}
234240
this.requestCount--;

0 commit comments

Comments
 (0)