Skip to content

Commit

Permalink
Add async handlers to nav-guard installers, change harvester route gu…
Browse files Browse the repository at this point in the history
…ard to be generic
  • Loading branch information
Richard authored and codyrancher committed Jul 8, 2024
1 parent cd15c8e commit 89286c3
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { tryInitialSetup } from '@shell/utils/auth';
import { routeRequiresAuthentication } from '@shell/utils/router';

export function install(router, context) {
router.beforeEach((to, from, next) => attemptFirstLogin(to, from, next, context));
router.beforeEach(async(to, from, next) => await attemptFirstLogin(to, from, next, context));
}

export async function attemptFirstLogin(to, from, next, { store }) {
Expand Down
2 changes: 1 addition & 1 deletion shell/config/router/navigation-guards/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { routeRequiresAuthentication } from '@shell/utils/router';
import { isLoggedIn, notLoggedIn, noAuth, findMe } from '@shell/utils/auth';

export function install(router, context) {
router.beforeEach((to, from, next) => authenticate(to, from, next, context));
router.beforeEach(async(to, from, next) => await authenticate(to, from, next, context));
}

export async function authenticate(to, from, next, { store }) {
Expand Down
2 changes: 1 addition & 1 deletion shell/config/router/navigation-guards/i18n.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export function install(router, context) {
router.beforeEach((to, from, next) => loadI18n(to, from, next, context));
router.beforeEach(async(to, from, next) => await loadI18n(to, from, next, context));
}

export async function loadI18n(to, from, next, { store }) {
Expand Down
4 changes: 2 additions & 2 deletions shell/config/router/navigation-guards/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { install as installLoadInitialSettings } from '@shell/config/router/navigation-guards/load-initial-settings';
import { install as installAttemptFirstLogin } from '@shell/config/router/navigation-guards/attempt-first-login';
import { install as installAuthentication } from '@shell/config/router/navigation-guards/authentication';
import { install as installHarvester } from '@shell/config/router/navigation-guards/harvester';
import { install as installRuntimeExtensionRoute } from '@shell/config/router/navigation-guards/runtime-extension-route';
import { install as installI18N } from '@shell/config/router/navigation-guards/i18n';

/**
Expand All @@ -11,7 +11,7 @@ export function installNavigationGuards(router, context) {
// NOTE: the order of the installation matters.
// Be intentional when adding, removing or modifying the guards that are installed.

const navigationGuardInstallers = [installLoadInitialSettings, installAttemptFirstLogin, installAuthentication, installHarvester, installI18N];
const navigationGuardInstallers = [installLoadInitialSettings, installAttemptFirstLogin, installAuthentication, installRuntimeExtensionRoute, installI18N];

navigationGuardInstallers.forEach((installer) => installer(router, context));
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fetchInitialSettings } from '@shell/utils/settings';

export function install(router, context) {
router.beforeEach((to, from, next) => loadInitialSettings(to, from, next, context));
router.beforeEach(async(to, from, next) => await loadInitialSettings(to, from, next, context));
}

export async function loadInitialSettings(to, from, next, { store }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import dynamicPluginLoader from '@shell/pkg/dynamic-plugin-loader';
import { routeRequiresAuthentication } from '@shell/utils/router';

export function install(router, context) {
router.beforeEach((to, from, next) => loadHarvester(to, from, next, context));
router.beforeEach((to, from, next) => runtimeExtensionRoute(to, from, next, context));
}

export async function loadHarvester(to, from, next, { store }) {
export async function runtimeExtensionRoute(to, from, next, { store }) {
if (!routeRequiresAuthentication(to) || to.name !== '404') {
return next();
}
Expand Down

0 comments on commit 89286c3

Please sign in to comment.